Hi everyone
A right newbie here so please take it easy on me!
I've been using the below code to do a tailored mail merge with specific attachments to my recipients.
There will be varied mailing, where some people will receive 1 attachment, and some with 3 for example.
The problem that I have is that if one of the cells with the attachment file name are empty, it doesn't go onto the next mailing and gives me an error message.
Is there some code I can include so if the 2nd / 3rd attachment cell are empty it moves onto the next person to send an email to?
It only works flawlessly if all 3 attachment cells are filled out at the moment!
I hope this makes sense, however I can try to explain it better!
Thanks in advance
D
A right newbie here so please take it easy on me!
I've been using the below code to do a tailored mail merge with specific attachments to my recipients.
There will be varied mailing, where some people will receive 1 attachment, and some with 3 for example.
The problem that I have is that if one of the cells with the attachment file name are empty, it doesn't go onto the next mailing and gives me an error message.
Is there some code I can include so if the 2nd / 3rd attachment cell are empty it moves onto the next person to send an email to?
It only works flawlessly if all 3 attachment cells are filled out at the moment!
I hope this makes sense, however I can try to explain it better!
Thanks in advance
D
Sub SendMail()
Dim objOutlook As Object
Dim objMail As Object
Dim ws As Worksheet
Set objOutlook = CreateObject("Outlook.Application")
Set ws = ActiveSheet
For Each cell In ws.Range("A2:A70")
Set objMail = objOutlook.CreateItem(0)
With objMail
.To = cell.Value
.Subject = cell.Offset(0, 2).Value
.Body = cell.Offset(0, 4).Value
.Attachments.Add cell.Offset(0, 5).Value
.Attachments.Add cell.Offset(0, 6).Value
.Attachments.Add cell.Offset(0, 7).Value
.send
End With
Set objMail = Nothing
Next cell
Set ws = Nothing
Set objOutlook = Nothing
End Sub