CDOSYS and Unicode in the from field

痴心易碎 提交于 2019-12-31 06:59:26

问题


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

回答1:


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


来源:https://stackoverflow.com/questions/2386843/cdosys-and-unicode-in-the-from-field

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