VBA Email with multiple To: and CC: addresses.

Brboland

New Member
Joined
Nov 19, 2021
Messages
15
Office Version
  1. 365
Platform
  1. Windows
I'm using VBA to send multiple emails. I currently have only one To: address in column "AF" and only one CC: address from "AI". I would like to add another address to both To: and CC: Below is how the code is set up.

VBA Code:
            Set OutMail = OutApp.CreateItem(0)
            On Error Resume Next
            With OutMail
                .SentOnBehalfOfName = "Somebody@abc.com"
                .From = "Somebody@abc.com"
                .to = cell.Value & AK
                .CC = Cells(cell.Row, "AI" & "AL").Value
                .Subject = "FY24 CACI Annual Government Property Inventory Request " & Cells(cell.Row, "K").Value & "\" & Cells(cell.Row, "M").Value & " Program " & Cells(cell.Row, "A").Value
                .HTMLBody = strbody & "<br>" & .HTMLBody
 
Last edited by a moderator:

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Where are the other email addresses you want to add?

The simplest way is to add ";" and then the other email address.
 
Upvote 0
I give you a couple of examples:


Rich (BB code):
  Set OutMail = OutApp.CreateItem(0)
  On Error Resume Next
  With OutMail
    .SentOnBehalfOfName = "Governmentpropertyinbox@caci.com"
    .From = "Governmentpropertyinbox@caci.com"
    .to = cell.Value & ";" & Cells(cell.Row, "AK").Value
    .CC = Cells(cell.Row, "AI").Value & ";" & Cells(cell.Row, "AJ").Value
    .Subject = "FY24 CACI Annual Government Property Inventory Request " & Cells(cell.Row, "K").Value & "\" & Cells(cell.Row, "M").Value & " Program " & Cells(cell.Row, "A").Value
    .HTMLBody = strbody & "<br>" & .HTMLBody
  End With
 
Upvote 0
Solution
I give you a couple of examples:


Rich (BB code):
  Set OutMail = OutApp.CreateItem(0)
  On Error Resume Next
  With OutMail
    .SentOnBehalfOfName = "Governmentpropertyinbox@caci.com"
    .From = "Governmentpropertyinbox@caci.com"
    .to = cell.Value & ";" & Cells(cell.Row, "AK").Value
    .CC = Cells(cell.Row, "AI").Value & ";" & Cells(cell.Row, "AJ").Value
    .Subject = "FY24 CACI Annual Government Property Inventory Request " & Cells(cell.Row, "K").Value & "\" & Cells(cell.Row, "M").Value & " Program " & Cells(cell.Row, "A").Value
    .HTMLBody = strbody & "<br>" & .HTMLBody
  End With
Your response added the email address from cell "AK" in the To: field.
In the CC: field, there was no change and only one email address was entered. Do you have any other suggestions?
 
Upvote 0
I gave examples, so that you can put the cells from which you want to add more emails. Since you did not indicate where the other emails should be taken from.

Rich (BB code):
    .to = cell.Value & ";" & Cells(cell.Row, "AK").Value
    .CC = Cells(cell.Row, "AI").Value & ";" & Cells(cell.Row, "AJ").Value

You must verify that the cell has an email. If the cell is empty it will not put anything in it.
Each cell you add must be separated by ";", just as I gave the examples.
 
Upvote 0
I gave examples, so that you can put the cells from which you want to add more emails. Since you did not indicate where the other emails should be taken from.

Rich (BB code):
    .to = cell.Value & ";" & Cells(cell.Row, "AK").Value
    .CC = Cells(cell.Row, "AI").Value & ";" & Cells(cell.Row, "AJ").Value

You must verify that the cell has an email. If the cell is empty it will not put anything in it.
Each cell you add must be separated by ";", just as I gave the examples.
Each email is dependent on each row. The email body is strbody text. The email address from cell.Value is actually column "AF". The example for the .to reference added the second email address from column "AK" and is working as you proposed. When I copied the example for the .CC, the only email address entered was the column "AI" email. Still not entering the email from column "AJ". Does that make sense? Is this task possible?

DanteAmor, I found a formatting error with the email in the final column. Correcting that formatting error allowed the perfect result. I appreciate your help and quick suggestions.
 
Last edited:
Upvote 1

Forum statistics

Threads
1,224,813
Messages
6,181,112
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top