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


                    Le Café Central de
Deva              

                                 
                                 ..... Deva blogs!!




 

 

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

  • Comments 1

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 
...

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.

Blog - Post Feedback Form(CAPTCHA)
Leave a Comment
  • Post