How do I use CDO with Exchange with vbscript

前端 未结 1 2177
孤独总比滥情好
孤独总比滥情好 2021-01-03 12:13

I am trying to setup a script to email using an exchange account. I want to use CDO (or equivalent) with vbscript. The goal is to track email communications through the sent

相关标签:
1条回答
  • 2021-01-03 12:34

    Use Microsoft NTLM (http://msdn.microsoft.com/en-us/library/aa378749(v=vs.85).aspx) In CDO it's a CdoProtocolsAuthentication Enum (http://msdn.microsoft.com/en-us/library/ms526961(v=exchg.10).aspx)

    Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory. 
    Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network). 
    
    Const cdoAnonymous = 0 'Do not authenticate
    Const cdoBasic = 1 'basic (clear-text) authentication
    Const cdoNTLM = 2 'NTLM
    
    dim objEmail
        Set objEmail = CreateObject("CDO.Message") 
    objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")= cdoSendUsingPort 
    'Name or IP of remote SMTP server
    objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="exchange"
    'Server port
    objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =25 
    
    objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpAuthenticate") = cdoNTLM 
    objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/NNTPAccountName") = "USERNAME"
     objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/SaveSentItems") = TRUE
    
    objEmail.Configuration.Fields.Update
    objEmail.From = "FROM <FROM@domain.com>"
        objEmail.To = "TO@domain.com"
        objEmail.Subject = "SUBJECT"
        objEmail.Textbody = "BODY " 
        objEmail.Send
    
    0 讨论(0)
提交回复
热议问题