Hi,
I have this VBA code below that works, however, in the message body of my email, all the text comes out in one line, what am I doing wrong?
I've tried Chr(13), Chr(10), vbCr, vbLF, and vbCrLf? I thought it might be the ".BodyFormat = olFormatRichText" that I commented out, but when I take the comment out, that line I get an error: Run-time error 5 Invalid procedure call or argument?
In the body of the email I want it to be formatted like this:
See Attachment:
Outside Service Report Summary: Vendor Name - 12/5/2018 - 1:17:32 PM - 1st Shipment - RECEIVED
I hope someone can help!
Thanks,
Xavier
---------------------------------------
Dim strEmail As String
strEmail = Me.txtEmailAddress
strPath = "P:\AccessDB\Outside Service\Excel_Files" 'Edit to your path
strFilter = [txtFileName]
strFile = Dir(strPath & strFilter)
If strFile <> "" Then
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook
' '.BodyFormat = olFormatRichText
.To = strEmail
''.cc = ""
''.bcc = ""
.Subject = [txtSubjectLine] & " - " & [txtSentReceived]
.HTMLBody = "See Attachment:" & Chr(13) & Chr(10) & "Outside Service " & [Forms]![frm_01d_Reports]![txtSubjectLine] & _
" - " & [Forms]![frm_01d_Reports]![txtSentReceived]
'.HTMLBody = "text here"
.Attachments.Add (strPath & strFile)
.Send
'.Display 'Used during testing without sending (Comment out .Send if using this line)
End With
Else
MsgBox "No file matching " & strPath & strFilter & " found." & vbCrLf & _
"Processing terminated."
Exit Sub 'This line only required if more code past End If
End If
---------------------------------------