Email Help

smartguy

Well-known Member
Joined
Jul 14, 2009
Messages
778
Hello all,

I have excel file in the below format.

Excel Workbook
ABC
1NameD.O.BEmail
2Kavi15-Markavi@ty.com
3Subu29-Novsubu@ty.com
Sheet1


Based on Date of Birth mail needs to send automatically.

It is possible?
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Maybe something like this then....

Code:
Sub Mailer()

    Dim OutApp As Object, OutMail As Object
    Dim rngCell As Range
               
    Set OutApp = CreateObject("Outlook.Application")
    OutApp.Session.Logon
    Set OutMail = OutApp.CreateItem(0)
    
    For Each rngCell In Range("B2:B" & Range("B" & Rows.Count).End(xlUp).Row)
        If DateSerial(Year(Date), Month(rngCell.Value), Day(rngCell.Value)) = Date Then
            With OutMail
                .To = rngCell.Offset(0, 1).Value
                .CC = ""
                .BCC = ""
                .Subject = "Happy Birthday"
                .Body = "Blah Blah Blah"
                .Display
            End With
                            
            Set OutMail = Nothing
            Set OutApp = Nothing
                               
            With Application
                waitTime = TimeSerial(Hour(Now()), Minute(Now()), Second(Now()) + 1)
                .Wait waitTime
                .SendKeys "%s~~~"
            End With
        End If
    Next rngCell
                
End Sub

Beware the .SendKeys line will send the emails, for testing it might be worth commenting this line out until your happy its working as expected.
 
Upvote 0
I mean, within the code, the sendkeys physically dispatches the email otherwise you end up with x no of open email items on your desktop.

Yes a button or event to trigger.
 
Upvote 0
I have one more Question.

The Excel sheet is always open.( all the days) it is possible the mail send automatically with out any manual work?
 
Upvote 0
I believe you can do it with an OnTime Event but i've not done it before, have a search of the board and that should help.
 
Upvote 0

Forum statistics

Threads
1,224,568
Messages
6,179,572
Members
452,927
Latest member
whitfieldcraig

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