CC a contact in outlook

LSA1991

New Member
Joined
Apr 17, 2016
Messages
3
Hi,
I am trying to figure out how to add an email address to an outlook email dependant on the value of a designated cell.
I can generate and send the email no problem but can not seem to add a cc recipient. any ideas?

Sub SendCompliants()

Dim IsCreated As Boolean
Dim i As Long
Dim PdfFile As String
Dim OutlApp As Object
Dim Title As String
Dim TitlePath As String
Dim NewMail As Object
Dim DistList As String
Dim LookupRng As String
Dim Segment As String
Dim Media As String
Dim Defence As String

'CC. Variable
Media = Range("G17").Value
Defence = Range("E17").Value

'Title of the document
Title = Range("C9").Value
TitlePath = "P:\Operational\Helpdesk\AA Sales\General Enquiries\Archived PDF Files (Do Not Use)\" & Title & ".pdf"
'LookupRng = Worksheets("Lookups").Range("A1:C14")

'LookupRng = "A1:D11"
'Segment = Range("E9").Value
'DistList = WorksheetFunction.VLookup(Segment, Worksheets("Lookups").Range(LookupRng), 3, 0)

ChDir "P:\Operational\Helpdesk\AA Sales\General Enquiries\Archived PDF Files (Do Not Use)"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
TitlePath, Quality _
:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False

Set OutlApp = CreateObject("Outlook.application")

' Prepare e-mail with PDF attachment

Set NewMail = OutlApp.CreateItem(0)

NewMail.Subject = "Current Client Query - " & Title
NewMail.to = "Please use Account Locator for recipient"
NewMail.SentOnBehalfOfName = "SPSHelpdesk.Sales.UK@sodexo.com"
'NewMail.to = DistList
NewMail.CC = "Rebecca.Symon@sodexo.com"
NewMail.CC = "pressoffice@sodexo.com"

NewMail.Body = "Good Day," & vbLf & vbLf _
& "Please find attatched a PDF file of a Client Query." & vbLf & vbLf _
& "Kind Regards," & vbLf _
& "Sales Admin Team" & vbLf & vbLf

NewMail.Attachments.Add TitlePath
NewMail.Display

' Try to send
On Error Resume Next
'NewMail.Send
Application.Visible = True
If Err Then
MsgBox "Unable to generate email please check form", vbExclamation
Else
MsgBox "E-mail has been opened, please manually send", vbInformation
End If
On Error GoTo 0

' Release the memory of object variable
Set OutlApp = Nothing

End Sub

This is my current coding and when I try to run it I get an error box "Block If without End If"
any help on this issue would be greatly appreciated.

Thank you.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
For more than one recipient, use a semi-colon to list them...

Code:
NewMail.CC = "Rebecca.Symon@sodexo.com;pressoffice@sodexo.com"

To use your variables, try...

Code:
NewMail.CC = Media & ";" & Defence

Hope this helps!
 
Upvote 0
For more than one recipient, use a semi-colon to list them...

Code:
NewMail.CC = "Rebecca.Symon@sodexo.com;pressoffice@sodexo.com"

To use your variables, try...

Code:
NewMail.CC = Media & ";" & Defence

Hope this helps!

------------------------------------------------------------------

Thank you for the reply,
however I need the email to cc in a contact dependant on cell E:17 having the value 'Yes'
is this at all possible?
 
Upvote 0
Try...

Code:
NewMail.CC = IIf(UCase(Rang("E17").Value) = "YES", Media & ";" & Defence, "")
 
Upvote 0

Forum statistics

Threads
1,215,234
Messages
6,123,773
Members
449,123
Latest member
StorageQueen24

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