添加额外的标题来发送VB ASP 3.0脚本 [英] Add extra header to email VB ASP 3.0 script

查看:112
本文介绍了添加额外的标题来发送VB ASP 3.0脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VB ASP 3.0中的Web应用程序。我有以下代码发送电子邮件:

  Const cdoSendUsingMethod = _ 
http://schemas.microsoft .com / cdo / configuration / sendusing
Const cdoSendUsingPort = 2
Const cdoSMTPServer = _
http://schemas.microsoft.com/cdo/configuration/smtpserver
Const cdoSMTPServerPort = _
http://schemas.microsoft.com/cdo/configuration/smtpserverport
Const cdoSMTPConnectionTimeout = _
http://schemas.microsoft.com/cdo/
Const cdoSendUserName = _
http://schemas.microsoft.com/cdo/configuration/sendusername
Const cdoSendPassword = _
http://schemas.microsoft.co m / cdo / configuration / sendpassword

设置objMessage = CreateObject(CDO.Message)
objMessage.Configuration.Fields.Item(http://schemas.microsoft.com/ cdo / configuration / sendusing)= 2
objMessage.Configuration.Fields.Item(http://schemas.microsoft.com/cdo/configuration/smtpauthenticate\")=1
objMessage.Configuration.Fields .Item(http://schemas.microsoft.com/cdo/configuration/sendusername\")=\"xxxxxxx
objMessage.Configuration.Fields.Item(http://schemas.microsoft.com/cdo/ configuration / sendpassword)=xxxxxxx
objMessage.Configuration.Fields.Item(http://schemas.microsoft.com/cdo/configuration/smtpusessl\")=false
objMessage.Configuration.Fields .Item(http://schemas.microsoft.com/cdo/configuration/smtpserver)=smtp.socketlabs.com

objMessage.Configuration.Fields.Update

fFromEmail =xxx@xxx.com
fFromAlias =显示名称
fReplyTo =xxx@xxx.com
if isObject(objMessage)then
With objMessage
.To = fToEmail
.Cc = fCCEmail
.Bcc = fBCCEmail
.From = fFromAlias& ; < &安培; fFromEmail& > 中
.Subject = fSubject
.HTMLBody = fEmailBody
。发送
结束

SendEmail = summaryEmailBody
设置objMessage = Nothing
如果

此脚本有效,但现在我需要添加一个额外的标题。但是我不能在.net框架中找到如何执行此操作。



我尝试添加以下行:

  objMessage.Configuration.Fields.Item(urn:schemas:mailheader:X-xsMailingId)=clientName
/ pre>

但它没有工作。任何帮助将不胜感激。

解决方案

您需要将标题添加到 objMessage.Fields collection而不是 objMessage.Configuration.Fields 根据官方文档(见VBScript部分)

  objMessage.Fields.Item(urn:schemas:mailheader:X-xsMailingId)=clientName
objMessage.Fields.Update

然后它应该工作。


I'm working with a web app in VB ASP 3.0. I have the following code to send an email:

    Const cdoSendUsingMethod        = _
            "http://schemas.microsoft.com/cdo/configuration/sendusing"
    Const cdoSendUsingPort          = 2
    Const cdoSMTPServer             = _
            "http://schemas.microsoft.com/cdo/configuration/smtpserver"
    Const cdoSMTPServerPort         = _
            "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
    Const cdoSMTPConnectionTimeout  = _
            "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
    Const cdoSMTPAuthenticate       = _
            "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
    Const cdoBasic                  = 1
    Const cdoSendUserName           = _
            "http://schemas.microsoft.com/cdo/configuration/sendusername"
    Const cdoSendPassword           = _
            "http://schemas.microsoft.com/cdo/configuration/sendpassword"

    Set objMessage = CreateObject("CDO.Message")
        objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2 
        objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")=1 
        objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername")="xxxxxxx"
        objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword")="xxxxxxx" 
        objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl")=false 
        objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.socketlabs.com"

        objMessage.Configuration.Fields.Update 

    fFromEmail = "xxx@xxx.com"
    fFromAlias = "Display name"
    fReplyTo = "xxx@xxx.com"
    if isObject(objMessage) then
        With objMessage
            .To       = fToEmail
            .Cc      = fCCEmail
            .Bcc      = fBCCEmail
            .From     = fFromAlias & "<" & fFromEmail & ">"
            .Subject  = fSubject
            .HTMLBody = fEmailBody
            .Send
        End With

        SendEmail = summaryEmailBody
        Set objMessage = Nothing
    End If

This script works, but now I need to add an extra header. But I can't find how to do so when not in a .net framework.

I tried adding the following line:

        objMessage.Configuration.Fields.Item("urn:schemas:mailheader:X-xsMailingId") = "clientName"

but it didn't work. Any help will be greatly appreciated.

解决方案

You need to add the header into the objMessage.Fields collection instead of objMessage.Configuration.Fields according to official documentation (see VBScript section)

objMessage.Fields.Item("urn:schemas:mailheader:X-xsMailingId") = "clientName"
objMessage.Fields.Update

Then it should work.

这篇关于添加额外的标题来发送VB ASP 3.0脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆