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

excel vba, add multiple .To email addresses

我正在使用以下代码通过 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

尝试使用分号代替逗号:

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

使用;而不是,

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