Dark Bit Factory & Gravity

PROGRAMMING => General coding questions => Topic started by: Shockwave on January 07, 2010

Title: HTML in emails
Post by: Shockwave on January 07, 2010
I was shown a visual basic application by a colleague in work today, the application took some values from a microsoft excel spreadsheet and stored them in some strings, it then concatenated them together and sent them to a list of email addresses.

I was asked if it would be possible to apply text formatting to the email and I thought that it would just be a matter of adding html tags inside the strings so we tested it out and the tags were just sent as plain text along with the rest of the email.

I since researched the problem a little online and it appears that it is not as clear cut as I thought.

So my question is (and I don't know if anyone has the answer) : lets pretend I wanted to add the bold tag and the h1 tags to an email and send it in html format using visual basic.. Is there any way to do this?
Title: Re: HTML in emails
Post by: rdc on January 07, 2010
Maybe this will help:

http://mailformat.dan.info/body/html.html

It appears that you need to make sure the header is formatted correctly in order for it to work properly.
Title: Re: HTML in emails
Post by: benny! on January 07, 2010
Right, I think if you set the MIME type to text/html it might work.

A general note though:
Keep in mind the variety of mail clients - even if text/html is set
some mail clients won't interpret all HTML tags (correctly). In addition
a lot of users seem to disable the HTML view in mails.

Anyway, Good Luck!
Title: Re: HTML in emails
Post by: Shockwave on January 08, 2010
Thanks for the advice.

Bearing in mind that people do disable HTML in emails sometimes, is there a way of displaying and formatting text as rich text instead?
Title: Re: HTML in emails
Post by: Jim on January 08, 2010
There are lots of mime types, I suspect that Outlook would understand text/rtf or application/rtf in the headers along with the html ones.  But I don't think there's a standard that an email client must have except 7bit ascii.

Jim
Title: Re: HTML in emails
Post by: Shockwave on January 08, 2010
Ok, cheers Jim.
Title: Re: HTML in emails
Post by: benny! on January 09, 2010
Here is a link as an example of what Outlook 2007 supports
and what not.

http://msdn.microsoft.com/en-us/library/aa338201.aspx (http://msdn.microsoft.com/en-us/library/aa338201.aspx)

Again, this is just an example of one version of an email client.
Personally, I would try to keep the formatting tags as simple as
possible.

Maybe someone has a intersection list of HTML/CSS which are
supported by all common email clients  ::)
Title: Re: HTML in emails
Post by: Shockwave on January 09, 2010
Changing the header to use text/html was all that was needed to make it work, thanks :)
Title: Re: HTML in emails
Post by: Jim on January 09, 2010
Gotta love the community comments at the bottom of the page that Benny linked to.
Quote
YOU REALLY ARE STUPID!
I didn't know that the latest Outlook replaced IE's html rendering engine with a cut down one.

Great that you got it fixed Shockwave!

Jim
Title: Re: HTML in emails
Post by: benny! on January 10, 2010
lol ... true...