excel vba,添加多个.To电子邮件地址

时间:2015-01-16 09:52:19

标签: excel vba excel-vba

我使用以下代码使用VBA发送电子邮件。但是,没有发送电子邮件...我认为这是由于' .To ='中的多个电子邮件地址。代码行。有没有办法调整代码以允许多个电子邮件地址?

我试过看过Ron de Bruin的例子但是,我只是无法得到任何工作?

Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object

Set rng = Nothing
On Error Resume Next
Set rng = Selection.SpecialCells(xlCellTypeVisible)
On Error GoTo 0

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
    .To = "bob.johnson@email.com, john.smith@email.com"
    .CC = ""
    .BCC = ""
    .Subject = "Open Orders where LF print to center of disc is required - " & Format(Now, "dd/mm/yyyy HH:mm")
    .HTMLBody = "Please ensure discs for the following orders are run on replication lines that allow LF print to be printed to the center of the disc. " & Chr(10) & _
    RangetoHTML(rng)
    .Send
End With

2 个答案:

答案 0 :(得分:2)

尝试使用分号而不是逗号:

With OutMail
    '.To = "bob.johnson@email.com, john.smith@email.com"
    .To = "bob.johnson@email.com; john.smith@email.com"

答案 1 :(得分:-1)

使用;而不是,

.To = "bob.johnson@email.com; john.smith@email.com"