Need help sending an automated email in outlook using VBA while attaching a PDF from a folder location. Below is what I have thus far. I'm stuck on the part to attach the PDF
Sub ViolationProcessingTest()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "<BODY style = font-size:11pt;font-family:Calibri>" & _
"Hello, <br><br> Please process the attached violations."
On Error Resume Next
With OutMail
.To = "email@email.com"
.CC = "email@email.com"
.Subject = "Violations Processing"
.Display
.HTMLBody = strbody & .HTMLBody
.Attachments.Add = "Folder path location with PDF"
End With
On Error GoTo 0
Set OutMail = Nothing
End Sub
Firstly, it is a good idea to get rid of the On Error Resume Next
line - errors are raised for a reason, otherwise you won't even know why or where your code is failing.
Secondly, your code is almost OK, you just need to get rid of =
(it is a method call, not a property assignment) and specify a fully qualified PDF file name:
.Attachments.Add "c:\SomeFolder\TheFile.PDF"