SMORF
SMORF

Reputation: 499

excel vba, add multiple .To email addresses

I am using the following code to send an email using VBA. But, no email is sent ... I think this is due to more than one email address in the '.To = ' code line. Is there a way of adapting the code to allow multiple email addresses?

I've tried looking at Ron de Bruin examples but, I just cant get anything to work?

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 = "[email protected], [email protected]"
    .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

Upvotes: 2

Views: 11973

Answers (2)

Kᴀτᴢ
Kᴀτᴢ

Reputation: 2176

Use ; instead of ,

.To = "[email protected]; [email protected]"

Upvotes: 0

Leo Chapiro
Leo Chapiro

Reputation: 13994

Try to use the semicolon instead of comma:

With OutMail
    '.To = "[email protected], [email protected]"
    .To = "[email protected]; [email protected]"

Upvotes: 2

Related Questions