Sub bdMail() Dim OutApp As Object Dim OutMail As Object Dim cell As Range Dim lastRow As Long Dim dateCell As Date Application.ScreenUpdating = False Set OutApp = CreateObject("Outlook.Application") OutApp.Session.Logon lastRow = Range("A" & Rows.Count).End(xlUp).Row On Error GoTo cleanup For Each cell In Range("D2:D" & lastRow) dateCell = cell.Value If Day(dateCell) = Day(Date) And Month(dateCell) = Month(Date) Then Set OutMail = OutApp.CreateItem(0) On Error Resume Next With OutMail .To = cell.Offset(0, 1).Value .Subject = "Happy Birthday" .Body = "Dear " & Cells(cell.Row, "C").Value _ & vbNewLine & vbNewLine & _ "Many Happy Returns of the Day " _ & vbNewLine & vbNewLine _ & vbNewLine & vbNewLine & _ "Cheers," & vbNewLine & _ "Rahul" .send End With On Error GoTo 0 Set OutMail = Nothing End If Next cell cleanup: Set OutApp = Nothing Application.ScreenUpdating = True End Sub
Glad we were able to help! Love us? Write us a review! Rate CCM
5637 users have said thank you to us this month
DON'T MISS
It was very very helpful. Many Thanks!
Could you please e-mail me this code by taking into consideration changing body text color, font and style.
Looking forward to getting your sooner reply!
BR,
Gunay
Please elaborate the steps also, how to use this code.
Thanks