Hi Everyone
I am trying to use the following Code to generate an Email which includes multiple lines in the Msg Body as well as attach a Report and a PDF File.
Currently when I run the code I get :-
1 Email which has the "rptCariProviderLetter" attached plus another EMail which has the Multiple Text lines in the Msg Body.
It does not attach the PDF file "C:\HowtoCreateCARIAccountV43 & "" &.Pdf"
I have cross posted this on Utter Access https://www.utteraccess.com/topics/2.../posts/2768314
Is it possible to achieve the 3 options required in one Email or should I split it into 2 Emails?
Any help appreciated.
The Code is:-
Code:
Private Sub cmdEMail_Click()
10 On Error GoTo cmdEMail_Click_Error
20 If Me.Dirty = True Then Me.Dirty = False
Dim objOutlookAttach As Object
Dim strWhere As String
Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String
Dim strtxtName As String
Dim strDocName As String
30 strDocName = "rptCariProviderLetter"
40 strWhere = "[CustomerID]=" & Me.CustomerID
50 strSubject = "CARI Stages to be Completed"
60 strToWhom = Nz(Me![Email])
'70 strMsgBody = "Find attached details of the next Stage to be completed."
70 Set OutApp = CreateObject("Outlook.Application")
80 Set OutMail = OutApp.CreateItem(0)
90 On Error Resume Next
100 With OutMail
110 .To = strToWhom
120 .Subject = strSubject
Dim mymsg As String
130 mymsg = "Onboarding Announcement:" & vbCrLf
140 mymsg = mymsg & "As a part of the Onboarding process, please ensure that the below two-step process" & vbCrLf
150 .body = mymsg
160 Attachments.Add "C:\HowtoCreateCARIAccountV43 & "" &.Pdf"
170 DoCmd.SendObject acSendReport, "rptCariProviderLetter", acFormatPDF, strToWhom, , , strSubject, strMsgBody, True
180 .Display
190 End With
'410 Set objApp = Nothing 'if / after you Send it
200 On Error GoTo 0
210 Exit Sub
cmdEMailReport_Click_Error:
220 MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdEMailReport_Click of Sub Form_qryInterviewList subform"
230 On Error GoTo 0
240 Exit Sub
cmdEMail_Click_Error:
250 MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdEMail_Click, line " & Erl & "."
End Sub