I am trying to send reminder email by using Excel and VBA. I am using Excel 2007 and Outlook 2007. When I run it showing messages in the Outlook and email has not been sent.
Here is the code
Sub send_mail()
Dim OutApp As Object
Dim outmail As Object
Dim mail_list As Range
Dim cell As Range
Application.ScreenUpdating = False
Set OutApp = CreateObject(“Outlook.Application”)
On Error GoTo error_exit
Set mail_list = Range(Range(“D3”), Range(“D3”).End(xlDown))
For Each cell In mail_list
Set outmail = OutApp.createitem(0)
On Error Resume Next
With outmail
.to = cell.Value
.Subject = “Reminder”
.body = “Postovana ” & Cells(cell.Row, “C”).Value & “,” & vbNewLine & vbNewLine & _
“Ovo je generisana poruka. Molim Vas da se javite na pregled.” & vbNewLine & vbNewLine & _
“Srdacan pozdrav” & vbNewLine & _
“dr Sandra Kljajic”
.display
End With
On Error GoTo 0
Set outmail = Nothing
Next cell
error_exit:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub
Can someone help me?
Rod is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.