VBA code to send automated emails to more than one cc

Reecenorman1996

New Member
Joined
Jul 20, 2023
Messages
31
Office Version
  1. 365
Platform
  1. Windows
Hi need help editing the below code to let me send the email to 2 people in cc in 2 columns at the moment its gets the cc form column k, but i want it to get email addresses from j and k and have 2 people in copy

thanks in advance

Sub Send_Bulk_Mails()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("sheet1")
Dim i As Integer

Dim OA As Object
Dim msg As Object

Set OA = CreateObject("outlook.application")

Dim last_row As Integer
last_row = Application.CountA(sh.Range("c:c"))

For i = 2 To last_row
Set msg = OA.createitem(0)
msg.to = sh.Range("i" & i).Value
msg.cc = sh.Range("k" & i).Value
msg.Subject = sh.Range("m" & i).Value
msg.Body = sh.Range("n" & i).Value

msg.send

sh.Range("p" & i).Value = "Sent"

Next i

MsgBox "All emails have been sent"

End Sub
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
change:
msg.cc = sh.Range("k" & i).Value

to:
msg.cc = sh.Range("k" & i).Value & ";" & sh.Range("j" & i).Value
 
Upvote 1
Solution
Hello! I am working with that same code and was wondering if the previous line is only meant for one recipient:
msg.cc = sh.Range("k" & i).Value

And if the subsequent code will send to multiple people as long as their addresses are separated by a ";"
msg.cc = sh.Range("k" & i).Value & ";" & sh.Range("j" & i).Value
 
Upvote 0
Hello! I am working with that same code and was wondering if the previous line is only meant for one recipient:
msg.cc = sh.Range("k" & i).Value

And if the subsequent code will send to multiple people as long as their addresses are separated by a ";"
msg.cc = sh.Range("k" & i).Value & ";" & sh.Range("j" & i).Value
I use in 2 columns so one email in column k and one in J like below

Cell Formulas
RangeFormula
I2:I17I2=IFERROR(VLOOKUP('Report results SA'!A3,Table2,2),)
J2:J17J2=IFERROR(VLOOKUP('Report results SA'!A3,Table26,2),)
K2:K17K2=IF('Report results SA'!G3>1,"Joanne fox","")
L2:L17L2='Report results SA'!F3
M2:M17M2=CONCAT([@Column1],CHAR(10),CHAR(10),[@Column3],CHAR(10),CHAR(10),[@Column4])
Cells with Conditional Formatting
CellConditionCell FormatStop If True
H2:H28Expression=O2>3textNO
H2:H28Expression=A2>3textNO
Cells with Data Validation
CellAllowCriteria
H2:H17List=lookuplists!$I$64:$I$72
 
Upvote 0

Forum statistics

Threads
1,215,091
Messages
6,123,062
Members
449,090
Latest member
fragment

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