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:

[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD]Name[/TD]
[TD]From[/TD]
[TD]Subject[/TD]
[TD]Birthday[/TD]
[/TR]
[TR]
[TD]mkp@123.com[/TD]
[TD]234@123.com[/TD]
[TD]Hello[/TD]
[TD]04-03-2013[/TD]
[/TR]
[TR]
[TD]mkp@123.com[/TD]
[TD]635@1213.com[/TD]
[TD]HI[/TD]
[TD]04-03-1999[/TD]
[/TR]
[TR]
[TD]123@123.com[/TD]
[TD]635@1213.com[/TD]
[TD]hello[/TD]
[TD]04-03-2001[/TD]
[/TR]
</tbody>[/TABLE]

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

Please help

 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

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