如何将CDO与Exchange一起使用vbscript

时间:2011-06-08 18:54:22

标签: vbscript exchange-server exchange-server-2007

我正在尝试使用交换帐户设置脚本来发送电子邮件。我想使用CDO(或等效的)与vbscript。目标是通过交换帐户的已发送文件夹跟踪电子邮件通信。 我正在使用Exchange 2007。

1 个答案:

答案 0 :(得分:3)

使用Microsoft NTLM(http://msdn.microsoft.com/en-us/library/aa378749(v=vs.85).aspx) 在CDO中,它是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