我尝试使用以下代码在VB6中添加自定义邮件头。但它没有用。 任何人都可以帮助我吗?
Dim lobj_cdomsg As CDO.Message
Set lobj_cdomsg = New CDO.Message
'Add the Project Reference Miscrosoft CDO WINDOWS FOR 2000
lobj_cdomsg.Configuration.Fields(cdoSMTPServer) = "servername"
lobj_cdomsg.Configuration.Fields(cdoSMTPConnectionTimeout) = 30
lobj_cdomsg.Configuration.Fields(cdoSendUsingMethod) = 2
lobj_cdomsg.Configuration.Fields(cdoSMTPAuthenticate) = 1
lobj_cdomsg.Configuration.Fields(cdoSendUserName) = "username"
lobj_cdomsg.Configuration.Fields(cdoSendPassword) = "password"
lobj_cdomsg.Configuration.Fields(cdoSMTPServerPort) = "587"
lobj_cdomsg.Configuration.Fields("urn:schemas:mailheader:X-MC-Tags") = "CKSR001"
'lobj_cdomsg.Fields("urn:schemas:mailheader:X-MC-Tags") = "CKSR002"
lobj_cdomsg.Configuration.Fields.Update
lobj_cdomsg.To = "to user"
lobj_cdomsg.From = "from"
lobj_cdomsg.Subject = "FROM VB6 CODSYS"
lobj_cdomsg.TextBody = "New Mail"
lobj_cdomsg.TextBody = "New Mail"
lobj_cdomsg.Send
Set lobj_cdomsg = Nothing
答案 0 :(得分:2)
您必须添加" urn:schemas:mailheader:X -..." header作为Message对象的字段,而不是Message.Configuration。
在发送邮件之前添加以下两行:(并删除您的非工作行)
lobj_cdomsg.Fields("urn:schemas:mailheader:X-MC-Tags") = "CKSR001"
lobj_cdomsg.Fields.Update
然后它应该工作。