简体   繁体   中英

CDO.Message encoding issue

We're currently changing our mail delivery system to use solely UTF-8 .

There seems to be a problem with the sender name, when the email contains non ASCII chars (hebrew) the subject & body render ok, but the sender name, as it appears in my gmail account, becomes - ?????? .

There is a line of code:

myMail.BodyPart.Charset = "UTF-8"

So I thought there should be some code of the like:

myMail.SenderName.Charset = "UTF-8"

But I can't seem to find the right code to use, assuming this would do the trick.

This works for me: http://www.powerasp.net/content/new/sending_email_cdosys.asp

Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message") 

ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "myserver"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

ObjSendMail.Configuration.Fields.Update

ObjSendMail.To = to_email
ObjSendMail.Subject = subject
ObjSendMail.From = from_email

'ObjSendMail.TextBody = mensaje   'tipo texto
ObjSendMail.HTMLBody = mensaje   'tipo html

ObjSendMail.TextBodyPart.Charset = "utf-8"  'support symbols á ñ ¡

ObjSendMail.Send

Set ObjSendMail = Nothing

This worked for me.

Set iMsg = CreateObject("CDO.Message")

With iMsg
    .BodyPart.Charset = "utf-8"
End With

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM