I have this code I have been using for a while which works to create an email with a PDF of a report. However I wanted to add a CC and tried several options found online but none seem to work. I have left them all in the code just for you to see what I tried but I tired them each separately
Code:
Private Sub emailTest_Click()
On Error GoTo emailTest_Click_Err
Sbj = RMAN & ".pdf"
DoCmd.OutputTo acOutputReport, "RAnalysisPDF", acFormatPDF, Sbj, , , , 0
Sbj = "Analysis Results for " & RMAN
fle = RMAN & ".pdf"
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Dim MailAttachment As Outlook.Attachments
'Option 1 Dim recipientTo As Outlook.Recipient
'Option 1 Dim recipientCC As Outlook.Recipient
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
'Option 1 recipientTo = Recipients.Add("name@domain.com")
'Option 1 recipientTo.Type = Outlook.OlMailRecipientType.olTo
'Option 1 recipientCC = Recipients.Add("name@domain.com")
'option 1 recipientCC.Type = Outlook.OlMailRecipientType.olCC
MailOutLook.Display
With MailOutLook
.subject = Sbj
'Option 2 recipientTo = Recipients.Add("name@domain.com")
'Option 2 recipientTo.Type = Outlook.OlMailRecipientType.olTo
'Option 2 recipientCC = Recipients.Add("name@domain.com")
'Option 2 recipientCC.Type = Outlook.OlMailRecipientType.olCC
'This works .Recipients.Add ("name@domain.com")
.Attachments.Add fle
.Display 'This will display the message for you to check and send yourself
End With
emailTest_Click_Exit:
Exit Sub
emailTest_Click_Err:
MsgBox Error$
Resume emailTest_Click_Exit
End Sub