Database and Customer Relationship Management with Excel VBA Video 2

In this video we describe how to send out birthday greeting automatically using Outlook:

Private Sub cmdBirthdays_Click()
Dim myApp As Outlook.Application, myMail As Outlook.MailItem
Dim LDay As Integer, M As Integer
Dim x As Long
lastrow = Sheets(“Main Database”).Cells(Rows.count, 1).End(xlUp).Row
For x = 2 To lastrow
LDay = Day(Cells(x, 6).Value)
DDay = Day(Date)

If LDay = DDay And Cells(x, 6).Value <> “” And Month(Cells(x, 6).Value) = Month(Date) Then
Set myApp = New Outlook.Application
Set myMail = myApp.CreateItem(olMailItem)
myMail.To = Cells(x, 5).Value

With myMail
.Subject = “Happy Birthday!”
.Body = “Many happy returns of the day.” & vbCrLf & “Clare Smith”
End With

Cells(x, 7) = “yes”
Cells(x, 7).Interior.ColorIndex = 3
Cells(x, 7).Font.ColorIndex = 2
Cells(x, 7).Font.Bold = True
End If
Set myApp = Nothing
Set myMail = Nothing
End Sub

Watch the training video below:

View video on YouTube

Download a sample file by clicking on the Excel icon:

Published by

Dinesh Kumar Takyar

Welcome to! My aim is to help you learn MS Excel including VBA. I always felt that a good way to learn something was to find solutions to problems in that domain. That is why I share these Excel videos with you. Mostly these are questions asked during my corporate training sessions. I've been training individuals and companies in computers since 1991. I did my B. Sc. (Vordiplom), M. Sc. (Diplom) and Ph.D. (Dr. rer. nat.) from Hamburg, Germany. The best thing about solving some of my visitor's questions is that I also gain new insights. For more Excel VBA solutions you may like to visit my YouTube channel: For a structured Excel VBA training course online you can visit:

2 thoughts on “Database and Customer Relationship Management with Excel VBA Video 2”

  1. Dir All,

    in my excel Vb outook Application kannot be accepted.
    can i use thinderbird mail programm and how?
    many thanks for your help

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.