VBA send email to 3 addresses in 3 different cells

floggingmolly

Board Regular
Joined
Sep 14, 2019
Messages
167
Office Version
  1. 365
Platform
  1. Windows
I have a code that sends an email with attachment. Each attachment needs to go to 3 different addresses which are in 3 different cells. I can get it to send to the address in column K, but I need it to also send to L and M. Here is the code I have so far. I'm not sure how to add multiple cells in the .To line. Any help would be greatly appreciated.

Code:
.Range("p" & CustRow).Value = TemplName 'Template Name
                                   .Range("q" & CustRow).Value = Now
                                    If .Range("R3").Value = "Email" Then
                                                  Set OutApp = CreateObject("Outlook.Application") 'Create Outlook Application
                                                  Set OutMail = OutApp.CreateItem(0) 'Create Email
                                                  With OutMail
                                                      .To = Sheet1.Range("K" & CustRow).Value
                                                      .Subject = "Hi, " & Sheet1.Range("F" & CustRow).Value & " We Miss You"
                                                      .Body = "Hello, " & Sheet1.Range("F" & CustRow).Value & " Its been a while since we have seen you so we wanted to send you a special letter. Please see the attached file"
                                                      .Attachments.Add FileName
                                                      .Display 'To send without Displaying change .Display to .Send
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Not tested, but couldn't you just concatenate the 3 cells' contents, and separate with a semicolon?

Code:
.Range("p" & CustRow).Value = TemplName 'Template Name
                                   .Range("q" & CustRow).Value = Now
                                    If .Range("R3").Value = "Email" Then
                                                  Set OutApp = CreateObject("Outlook.Application") 'Create Outlook Application
                                                  Set OutMail = OutApp.CreateItem(0) 'Create Email
                                                  With OutMail
                                                      .To = Sheet1.Range("K" & CustRow).Value & ";" & Sheet1.Range("L" & CustRow).Value & ";" Sheet1.Range("M" & CustRow).Value
                                                      .Subject = "Hi, " & Sheet1.Range("F" & CustRow).Value & " We Miss You"
                                                      .Body = "Hello, " & Sheet1.Range("F" & CustRow).Value & " Its been a while since we have seen you so we wanted to send you a special letter. Please see the attached file"
                                                      .Attachments.Add FileName
                                                      .Display 'To send without Displaying change .Display to .Send

You could clean it up a bit, but it should steer you in the right direction...
 
Upvote 0
Hi @sykes, It works, but missed a &

.To = Sheet1.Range("K" & CustRow).Value & ";" & Sheet1.Range("L" & CustRow).Value & ";" & Sheet1.Range("M" & CustRow).Value



Hi @floggingmolly, another option, You can increase more cells, just change the M to another column.

Code:
  .To = Join(WorksheetFunction.Transpose(WorksheetFunction.Transpose(Sheet1.Range("K" & CustRow & ":[B][COLOR=#0000ff]M[/COLOR][/B]" & CustRow).Value)), ";")
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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