Tag Archives: Unicode

Unicode mails send using CDOSYS & Bodypart show special or funny characters in message body


Recently I was working with a Customer who uses ASP & CDOSYS to send Unicode content e-mails. He had the following partial code-snippet:

...
Set objMail = Server.CreateObject("CDO.Message") 'Create CDO.Message Object
Set objBodyPart = objmail.BodyPart 'Create BodyPart
objBodyPart.Charset = "UTF-8" 'Set relevant Charset
 
Set objConf = Server.CreateObject("CDO.Configuration") 'Create Configuration Object
Set objFields = objConf.Fields 'and set its Configuration fields
 
With objFields 
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send using port or pickup
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost" 'Specify SMTPServer
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 20 'Specify timeout
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 'Specify the port
.Update 'Update the Configuration
End With 
 
With objMail 
Set .Configuration = objConf 'Set the configuration object
.From = email 'Set From users
.To = Trim(recip) 'Set recipients
.Subject = subject 'Set the subject
.TextBody = txString 'txtString contains the unicode chars
End With 
 
objMail.Send 'Send
'Release the objects
Set objFields = Nothing 
Set objConf = Nothing 
Set objMail = Nothing 
...

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

But he updated that he can display the information correctly in a web browser using UTF-8 encoding on the web page; But whenever he send the information

via email the Unicode values in the message body show the "special or funny" characters.He also tried setting the charset for the email but it doesn’t made any difference.

When we started troubleshooting we found that we need to set the HTMLBodyPart and TextBodyPart Charset in the above code, which resolved the issue.