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

excel vba,向电子邮件地址添加多个,vba,excel,Vba,Excel,我正在使用以下代码使用VBA发送电子邮件。但是,没有发送电子邮件。。。我认为这是由于“.to=”代码行中有多个电子邮件地址造成的。有没有办法修改代码以允许多个电子邮件地址 我试着看看罗恩·德·布鲁因的例子,但是,我就是不能让任何东西起作用 Dim rng As Range Dim OutApp As Object Dim OutMail As Object Set rng = Nothing On Error Resume Next Set rng = Selection.SpecialCel

我正在使用以下代码使用VBA发送电子邮件。但是,没有发送电子邮件。。。我认为这是由于“.to=”代码行中有多个电子邮件地址造成的。有没有办法修改代码以允许多个电子邮件地址

我试着看看罗恩·德·布鲁因的例子,但是,我就是不能让任何东西起作用

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"

卡茨,你怎么会有这种想法帽子还是一样,但我不得不等待3分钟,等待我的下一篇文章XD