How do I use CDO with Exchange with vbscript

浪尽此生 提交于 2019-11-30 00:09:24

问题


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 folder of the exchange account. I am using exchange 2007.


回答1:


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


来源:https://stackoverflow.com/questions/6283742/how-do-i-use-cdo-with-exchange-with-vbscript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!