VBA: Help fixing code to inlclude two CC's in email

neylon

New Member
Joined
Jun 29, 2016
Messages
30
Hi

I have the following macro that works fine to send the active workbook to one recipient and one CC, with reference to two cells:

Sub Mail_Workbook() 'Excel VBA to send mail.

Dim OutApp As Object
Dim OutMail As Object
Dim str1 As String
Dim str2 As String
Dim str3 As String
Dim str4 As String
Dim str5 As String

str1 = [N3]
str2 = [N1]
str3 = [N2]
str4 = [T4]
str5 = [T5]

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.TO = str1
.CC = str4
.Subject = str2
.Body = "Hello," & vbCrLf & vbCrLf & "Please find attached your latest statement." & vbCrLf & vbCrLf & "Please return your completed report by " & str3 & vbCrLf & vbCrLf & "Thank you" & vbCrLf & "Kind Regards,"
.Attachments.Add ActiveWorkbook.FullName
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing

End Sub


I tried the following to try and CC two people:
.CC = str4 & "; " & str5
however this doesn't work.

Can someone please help me get this to work?
Thank you so much
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
I tried the following to try and CC two people:
.CC = str4 & "; " & str5
however this doesn't work.

I tried the attached without the space after the semi colon and it worked fine. Can you also change the .send to .display and see what its coming up as?
 
Upvote 0
I tried the attached without the space after the semi colon and it worked fine. Can you also change the .send to .display and see what its coming up as?

Ah, it was a combination of the space and also I'd accidently changed the cell reference for one of the recipients.

All works fine now

Thanks for your help!
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,774
Members
452,353
Latest member
strainu

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