有没有办法用CDO指定我自己的message-id?
使用以下配置,仍然会由cdo组件生成message-id,并忽略我指定的那个。
<%
Const cdoSendUsingPort = 2
Dim iMsg, iConf, Flds
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
' set the CDOSYS configuration fields to use port 25 on the SMTP server
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp@example.com"
.Item("urn:schemas:mailheader:message-id") = "0123456789.0123456789@example.com"
.Update
End With
With iMsg
Set .Configuration = iConf
.From = "from@example.com"
.Subject = "test"
.To = "to@example.com"
.HTMLBody = "test"
.Send
End With
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
%>
答案 0 :(得分:2)
配置对象 iConf
与消息对象iMsg
无关,
你不需要创建它。
因此,请移除Set iConf = CreateObject("CDO.Configuration")
并将Set Flds = iConf.Fields
替换为Set Flds = iMsg.Fields
。 击>
您需要使用iMsg.Fields
为邮件设置标题。
Dim iMsg, iConf, Flds
Set iMsg = CreateObject("CDO.Message")
Set Flds = iMsg.Fields
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
' set the CDOSYS configuration fields to use port 25 on the SMTP server
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.example.com"
.Update
End With
With iMsg.Fields
.Item("urn:schemas:mailheader:message-id") = "0123456789.0123456789@example.com"
.Update
End With
With iMsg
Set .Configuration = iConf
.From = "from@example.com"
.Subject = "test"
.To = "to@example.com"
.HTMLBody = "test"
.Send
End With