Hello guys, I am trying to automatically send PDF's of invoices through Outlook, and I was able to send the PDF correctly, but once I switched up the code for a Dynamic name change, I can no long get VBA to find the PDF. Below is my code:
I need help with the myAttachments.Add "File" line.
Any help with this, would be greatly appreciated.
Code:
Sub sendReminderMail()ChDir "C:\Users\rbs\Desktop"
Dim Path As String
Dim filename As String
Dim File As String
Path = "C:\Users\rbs\Desktop\Invoices\"
filename = Range("B1") & Range("C1") & " - " & Range("B9")
File = Path & filename
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:= _
File, OpenAfterPublish:=True
Dim OutLookApp As Object
Dim OutLookMailItem As Object
Dim myAttachments As Object
Set OutLookApp = CreateObject("Outlook.application")
Set OutLookMailItem = OutLookApp.CreateItem(0)
Set myAttachments = OutLookMailItem.Attachments
With OutLookMailItem
.To = Range("B12")
.ReadReceiptRequested = True
.Subject = "Invoice #" & Range("C1")
.Body = "Thank you"
myAttachments.Add "File"
'.Send
.Display
End With
Set OutLookMailItem = Nothing
Set OutLookApp = Nothing
End Sub
I need help with the myAttachments.Add "File" line.
Any help with this, would be greatly appreciated.