Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
579 views
in Technique[技术] by (71.8m points)

vbscript - Add extra header to email VB ASP 3.0 script

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 = "[email protected]"
    fFromAlias = "Display name"
    fReplyTo = "[email protected]"
    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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...