VBA Excel发送多个电子邮件

时间:2018-04-18 18:52:44

标签: excel vba excel-vba

我正在尝试编写一个程序,向不同的经理发送电子邮件,告知他们的信息。对于某些情况,该程序将只发送一封电子邮件并说它已完成且没有错误。如何让它发送所有14封电子邮件。现在,电子邮件都指向我的直接电子邮件地址。请帮助!

Dim i As Integer
i = 1

Do While i <> 14
On Error Resume Next
With OutMail
    .to = SupervisorAddress(i)
    .CC = ""
    .BCC = ""
    .Subject = "QTF Expired"
    .Body = Body(i)
    'You can add a file like this
    '.Attachments.Add ("C:\test.txt")
    .Send   'or use .Display
End With
On Error GoTo 0
i = i + 1
Loop

1 个答案:

答案 0 :(得分:3)

Dim i As Long

For i = 1 To 14
    With OutApp.CreateItem(0)
        .to = SupervisorAddress(i)
        .CC = ""
        .BCC = ""
        .Subject = "QTF Expired"
        .Body = Body(i)
        'You can add a file like this
        '.Attachments.Add ("C:\test.txt")
        .Send   'or use .Display
    End With
Next