yaron hochman
yaron hochman

Reputation: 207

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.

Upvotes: 4

Views: 12125

Answers (3)

Michail
Michail

Reputation: 1

If you use HTMLBody then:

ObjSendMail.HTMLBodyPart.Charset = "utf-8"

Upvotes: 0

Unicco
Unicco

Reputation: 2580

This worked for me.

Set iMsg = CreateObject("CDO.Message")

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

Upvotes: 1

Hernaldo Gonzalez
Hernaldo Gonzalez

Reputation: 2046

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

Upvotes: 1

Related Questions