PDA

View Full Version : Solved: Mailer code depending on variables in columns



khaledocom
11-14-2011, 10:18 PM
Good morning all,

I explained what I need exactly in the attached XL file.

Thankful in advance for your help and cooperation.

Have a good day

mancubus
11-15-2011, 04:01 AM
this will display the messages, and in order to send, click SEND one by one

Sub MailAll()

On Error Resume Next
For i = 2 To Range("C" & Rows.Count).End(xlUp).Row
Set olApp = CreateObject("Outlook.Application")
Set olMail = olApp.CreateItem(olMailItem)
With olMail
.To = Cells(i, "C")
.CC = ""
.BCC = ""
.Subject = "Pending Vendor Invoices In Workflow as of " & Format(Now, "dd.mm.yyyy")
.Body = "Dear Mr. " & Cells(i, "B").Value & vbNewLine & vbNewLine & _
"Please find below list of pending invoices in your workflow for further action:" & vbNewLine & _
"PO No. " & Cells(i, "G").Value & " and Invoice No " & Cells(i, "J").Value & _
" are with you for " & Cells(i, "E").Value & ", which is outstanding for " & Cells(i, "G").Value & _
" Days." & vbNewLine & "Please take proper action ASAP." & vbNewLine & vbNewLine & _
"Kind regards." & vbNewLine & vbNewLine & "First Name and Last Name"
.Display
End With
Set olApp = Nothing
Set olMail = Nothing
Next
On Error GoTo 0

End Sub

khaledocom
11-16-2011, 12:25 AM
Gr8

Thanks a lot dear brother.