emailunicodevbscriptlocalizationcdo.message

CDOSYS and Unicode in the from field


I've got the code below, and I'm trying to set the from field to allow Unicode. Currently in my email client I get "??".

The subject line and any content shows the Unicode correctly. And looking at the MSDN, the property should be "urn:schemas:httpmail:from".

Anyone solved this issue?

Dim AC_EMAIL : AC_EMAIL = "test@test.com"
Dim AC_EMAIL_FROM : AC_EMAIL_FROM = "测试 <test@test.com>"
Dim strSubject : strSubject = """测试"" testing testing"

set oMessage = WScript.CreateObject("CDO.Message")

With oMessage
    .BodyPart.charset = "utf-8" 'unicode-1-1-utf-8
    .Fields("urn:schemas:httpmail:from") = AC_EMAIL_FROM
    .Fields("urn:schemas:httpmail:to") = AC_EMAIL
    .Fields("urn:schemas:httpmail:subject") = strSubject
    .Fields.Update
    .Send
End With

Set oMessage = Nothing

Solution

  • Found a work around. Not the prettiest, but it works. Basically I converted the string to Quoted-Printable.

    .Fields("urn:schemas:httpmail:from") = "=?utf-8?Q?=E6=8F?= <test@test.com>"