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

 

 

 

 

No Comments