Chris Garrett

Just Another Web Geek

June 2005 - Posts

Emailing Unicode Emails to Hotmail - solved!

In my last blog I asked how I could send unicode emails to hotmail, well Dave Wanta and www.AspNetEmail.com (no affiliate code, heh) to the rescue!

The AspNetEmail message takes a CharSet property, so far so good

As well as setting the CharSet to the relevant country setting, I found I also needed to HTML encode my message. I worked up a simple function knowing there was probably a better way ..

'HtmlBody = Server.HtmlEncode(HtmlBody)

'HtmlBody = Replace(HtmlBody, "&lt;", "<", 1, -1, CompareMethod.Text)

'HtmlBody = Replace(HtmlBody, "&gt;", ">", 1, -1, CompareMethod.Text)

'HtmlBody = Replace(HtmlBody, "&quot;", """", 1, -1, CompareMethod.Text)

'HtmlBody = Replace(HtmlBody, "&apos;", "'", 1, -1, CompareMethod.Text)

'HtmlBody = Replace(HtmlBody, "&amp;", "&", 1, -1, CompareMethod.Text)

 

.. and there was, already in AspNetEmail component - schweet!

Dim Util As New aspNetEmail.HtmlUtility

Util.LoadString(HtmlBody, "http://www.URL.com/")

Util.HtmlEncodeOption = HtmlEncodeOption.NumberedCodes

Util.Render()

HtmlBody = Util.RenderedHtmlContent

msg.HtmlBodyPart = HtmlBody

 

 

 

 

Posted: Jun 07 2005, 05:27 PM by Chris Garrett | with no comments
Filed under:
Emailing UTF-8 to Hotmail?

It looks suspiciously like Hotmail explicitly rejects viewing UTF-8 encoded email - is this correct?

Unfortunately my content is in UTF-8 and I can't just ignore Hotmail users :O(

I am using AspNetEmail and I tried using ISO-8859-1 as the characterset. Didn't work. So I tried converting my UTF-8 encoded text into ISO-8859-1 using the following function

Function UTFISO(ByVal src As String) As String

Dim iso As Encoding = Encoding.GetEncoding("iso-8859-1")

Dim utf As Encoding = Encoding.UTF8

Dim unicodeBytes As Byte() = utf.GetBytes(src)

Return iso.GetString(unicodeBytes)

End Function

Still no joy.

Any ideas anyone?

Posted: Jun 06 2005, 05:26 PM by Chris Garrett | with 6 comment(s)
Filed under:
More Posts