Excel Macro to send Birthday email via Outlook

MKP1964

New Member
Joined
Apr 1, 2013
Messages
2
Dear Friends,

Greetings to you all!

I used Mr.Domenic code for this:


Option ExplicitSub test() Dim OutlookApp As Outlook.Application Dim MItem As Outlook.MailItem Dim Rng As Range Dim Rw As Range Application.ScreenUpdating = False ActiveSheet.AutoFilterMode = False With ActiveSheet.UsedRange .AutoFilter field:=5, Criteria1:=">=" & Date, Operator:=xlAnd, Criteria2:="<=" & Date On Error Resume Next Set Rng = .Resize(.Rows.Count - 1).Offset(1, 0).SpecialCells(xlCellTypeVisible) On Error GoTo 0 End With If Not Rng Is Nothing Then Set OutlookApp = CreateObject("Outlook.Application") For Each Rw In Rng.Rows Set MItem = OutlookApp.CreateItem(olMailItem) With MItem .To = Rw.Cells(1, 1).Value .CC = "" .BCC = "" .Subject = Rw.Cells(1, 3).Value .Body = Rw.Cells(1, 4).Value .Save End With Next Rw Else MsgBox "No birthdays today!", vbExclamation End If ActiveSheet.AutoFilterMode = False Application.ScreenUpdating = True End Sub</pre>

I use Excel 2007. The works fine for dates with current year. And does not pick up older years with the same month and day. I tested with the following data:

NameFromSubjectBirthday
mkp@123.com234@123.comHello04-03-2013
mkp@123.com635@1213.comHI04-03-1999
123@123.com635@1213.comhello04-03-2001

<tbody>
</tbody>

Excel picked only the row with today's row:
04-03-2013
and left out 1999 and 2001.

Please help

 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,215,455
Messages
6,124,937
Members
449,196
Latest member
Maxkapoor

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top