使用 cdo.message 发送电子邮件时指定我自己的 message-id header
Specify my own message-id header when sending email with cdo.message
有没有办法用 CDO 指定我自己的 message-id?
使用下面的配置,message-id仍然是cdo组件生成的,忽略我指定的
<%
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
%>
配置objectiConf
与消息无关objectiMsg
,
你不需要创建它。
因此,删除 Set iConf = CreateObject("CDO.Configuration")
并将 Set Flds = iConf.Fields
替换为 Set Flds = iMsg.Fields
。
您需要使用iMsg.Fields
为消息设置headers。
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
有没有办法用 CDO 指定我自己的 message-id?
使用下面的配置,message-id仍然是cdo组件生成的,忽略我指定的
<%
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
%>
配置objectiConf
与消息无关objectiMsg
,
你不需要创建它。
因此,删除 Set iConf = CreateObject("CDO.Configuration")
并将 Set Flds = iConf.Fields
替换为 Set Flds = iMsg.Fields
。
您需要使用iMsg.Fields
为消息设置headers。
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