2012-07-03 153 views
7

我的vbscript自动发送电子邮件给收件人,但没有人知道如何添加多个收件人吗?使用vbscript发送电子邮件给多个收件人

... 
Dim ToAddress 
Dim FromAddress 
Dim MessageSubject 
Dim MyTime 
Dim MessageBody 
Dim MessageAttachment 
Dim ol, ns, newMail 
MyTime = Now 

ToAddress = "[email protected]" 
MessageSubject = "It works!." 
MessageBody = "Good job on that script." 
MessageAttachment = some attachment 
Set ol = WScript.CreateObject("Outlook.Application") 
Set ns = ol.getNamespace("MAPI") 
Set newMail = ol.CreateItem(olMailItem) 
newMail.Subject = MessageSubject 
newMail.Body = MessageBody & vbCrLf & MyTime 
newMail.RecipIents.Add(ToAddress) 
newMail.Attachments.Add(MessageAttachment) 
newMail.Send 

这就是我现在所拥有的。它工作正常。但是,我想要有多个收件人。提前致谢。

newMail.CC = "[email protected];[email protected];[email protected]" 

这条线以上工作!

它与.BCC的工作方式相同,以防万一任何人不想显示联系人列表。

+0

使用BCC代替CC。 – JimmyPena

+0

@JP。谢谢您的帮助。 – duper

回答

8

为每个收件人调用MailItem.Recipients.Add或将To/CC/BCC属性设置为“;”分开的地址列表。

相关问题