我的vbscript会自动向收件人发送电子邮件,但有人知道如何向其中添加多个收件人吗?
...
Dim ToAddress
Dim FromAddress
Dim MessageSubject
Dim MyTime
Dim MessageBody
Dim MessageAttachment
Dim ol, ns, newMail
MyTime = Now
ToAddress = "email@address.com"
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 = "person1@domain1.org;person2@domain2.org;person3@domain3.org"
以上这一行有效!
它与.BCC的工作方式相同,以防有人想要不显示联系人列表。
答案 0 :(得分:9)
为每个收件人调用MailItem.Recipients.Add或将To / CC / BCC属性设置为“;”分开的地址列表。