Novice
Novice

Reputation: 393

How to enter multiple email addresses in the Bcc property of the MailItem object?

My VBA Code sends automatic email. How to fill more then one email address?

User creates new email and fill:
To: one email address
Bcc: email address2, email address3, email address4, ...

How does Outlook separate each email address in the Bcc property to send in my example 4 emails instead of one.

Dim strWho As String
Dim strSubject As String
Dim objNewMail As Outlook.MailItem

Set objNewMail = Application.CreateItem(olMailItem)

strWho = objMail.To
strSubject = objMail.Subject 

With objNewMail
    .To = strWho
    .BCC = "mail2,mail3,mail4,mail5"
    .Subject = strSubject
    .Display
    .Send
End With

Upvotes: 1

Views: 1056

Answers (1)

Louis
Louis

Reputation: 3632

You should use the semicolon ; to separate each mail address, following this format:

"[email protected];[email protected]"

If you have them already typed into the mail object, you can use this code:

Dim strWho As String
Dim strSubject As String
Dim objNewMail As Outlook.MailItem
Dim bccMails As String

Set objNewMail = Application.CreateItem(olMailItem)

strWho = objMail.To
strSubject = objMail.Subject 
bccMails = objMail.BCC    

With objNewMail
    .To = strWho
    .BCC = bccMails
    .Subject = strSubject
    .Display
    .Send
End With

Otherwise you can ask the user once for the mail addresses with an InputBox and then using that value for every mail:

Dim bccMails As String
bccMails = InputBox("Please insert .bcc email addresses, separated by semicolons", "Email Address", "[email protected];[email protected]")

Hope this helps as a starting point.

Upvotes: 1

Related Questions