CDO.Message encoding issue

筅森魡賤 提交于 2020-01-21 12:22:14

问题


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.


回答1:


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



回答2:


This worked for me.

Set iMsg = CreateObject("CDO.Message")

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


来源:https://stackoverflow.com/questions/27420042/cdo-message-encoding-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!