Hi all,
I am trying to create a macro from a sheet formatted in the following way: (the sheet is a list of products we do not have in stock)
What I want to happen when I run the macro is an email is created/sent for each UNIQUE email address with a list of the parts that we have been unable to deliver to them.
So for the example above, the email would read:
Dear John,
Unfortunately, we have been unable to supply the following products to you today
Part A
Part C
Please call us on 01111111 if you would like to re-order when we fresh stock arrives,
Regards,
DEFAULT OUTLOOK SIGNATURE INCLUDED
I have played around with the following, but am struggling with a way to tell excel to compile all shorts with the same email...
Sub Test1()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "?*@?*.?*" And _
LCase(Cells(cell.Row, "C").Value) = "yes" Then
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = cell.Value
.Subject = "Reminder"
.Body = "Dear " & Cells(cell.Row, "A").Value _
& vbNewLine & vbNewLine & _
"Unfortunately, we have been unable to supply the following products to you today " & _
vbNewLine & vbNewLine & _
Cells(cell.Row, "A").Value _
'You can add files also like this
'.Attachments.Add ("C:\test.txt")
.Send 'Or use Display
End With
On Error GoTo 0
Set OutMail = Nothing
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub
Any help with this would be appreciated.
And also what code would include the default signature from my outlook?
Thanks in advance
Bookmarks