如何将CDO与Exchange和vbscript一起使用 [英] How do I use CDO with Exchange with vbscript

查看:133
本文介绍了如何将CDO与Exchange和vbscript一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

推荐答案

使用Microsoft NTLM( http://msdn.microsoft.com/zh-CN/library/ms526961(v=exchg.10).aspx )

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

这篇关于如何将CDO与Exchange和vbscript一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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