Hi,
I have a spreadsheet with 5 clients. email address and path to pdf doc. i have it working to the point it sends email to all 5 columns on the spreadsheet and attaches the pdf from the column that specifies the path to the pdf file. the issue i am currently looking for is when there is no pdf doc for a given client the code stops. i need the if statement to say if there is no pdf for a client on the list skip them and move onto the next client.
this is my vb code:
the spreadsheet looks like this:
I have a spreadsheet with 5 clients. email address and path to pdf doc. i have it working to the point it sends email to all 5 columns on the spreadsheet and attaches the pdf from the column that specifies the path to the pdf file. the issue i am currently looking for is when there is no pdf doc for a given client the code stops. i need the if statement to say if there is no pdf for a client on the list skip them and move onto the next client.
this is my vb code:
Sub Single_attachment()
Dim appOutlook As Object
Dim Email As Object
Dim Source, mailto As String
Dim intR As Integer
Set appOutlook = CreateObject("Outlook.Application")
Set Email = appOutlook.CreateItem(olMailItem)
intR = 2
For intR = 2 To 6
mailto = Cells(intR, 2)
Source = "C:\Users\fergus.kelly\Desktop\test eom invoices email\" & Cells(intR, 3)
Set Email = appOutlook.CreateItem(olMailItem)
With Email
.To = mailto
.Attachments.Add Source
.Subject = "Important Sheets"
.Body = "Greetings Everyone," & vbNewLine & "Please go through the Sheets." & vbNewLine & "Regards."
.send
End With
Next intR
End Sub
the spreadsheet looks like this: