Click here to Skip to main content
11,640,125 members (72,441 online)
Click here to Skip to main content

How to Create Birthday Reminders Using Microsoft Outlook, in C#

, 4 Jan 2004 CPOL 95.4K 2 40
Rate this:
Please Sign up or sign in to vote.
This article shows you hot to use Microsoft Outlook appointments. I used a version of the code to put reminders in for my family members.

Introduction

I guess it isn't rocket science to put birthday reminders into Outlook, but nevertheless, doing it in C# code cost me more effort than it should have. So without further ado, here is the code.

Steps

  1. Ensure you reference Microsoft Outlook, then create a new application.
    Outlook._Application olApp = 
       (Outlook._Application) new Outlook.Application();
  2. Log on. (I think email needs to be running)
    Outlook.NameSpace mapiNS = olApp.GetNamespace("MAPI")
    string profile = "";
    mapiNS.Logon(profile, null, null, null);
  3. Repeat the line.
    CreateYearlyAppointment(olApp, "Birthday", 
       "Kim", new DateTime(2004, 03,08, 7, 0, 0));

    for your wife and kids etc. etc.!!!

The Code

static void CreateYearlyAppointment(Outlook._Application olApp, 
    string reminderComment, string person, DateTime dt)
  {
   // Use the Outlook application object to create an appointment
   Outlook._AppointmentItem apt = (Outlook._AppointmentItem)
    olApp.CreateItem(Outlook.OlItemType.olAppointmentItem);
  
   // set some properties
   apt.Subject = person + " : " + reminderComment;
   apt.Body = reminderComment;
  
   apt.Start = dt;
   apt.End   = dt.AddHours(1);
 
   apt.ReminderMinutesBeforeStart = 24*60*7 * 1;  // One week reminder
   
   // Makes it appear bold in the calendar - which I like!
   apt.BusyStatus = Outlook.OlBusyStatus.olTentative; 
   
   apt.AllDayEvent = false;
   apt.Location = "";
   
   Outlook.RecurrencePattern myPattern = apt.GetRecurrencePattern();
   myPattern.RecurrenceType = Outlook.OlRecurrenceType.olRecursYearly;
   myPattern.Interval = 1;
   apt.Save();
  }

Reap The Rewards

With a one week reminder, you will never again forget your Mum's birthday.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Frank Eden
Web Developer
Australia Australia
Frank has been in computing since the age of the dinosaurs. He prefers playing table tennis to writing C#, C++, VB, or any of the other dozen or more languages he has written since the Jurasic.

You may also be interested in...

Comments and Discussions

 
GeneralError when creating birthday reminder in ASP.NET Pin
Simomo23-Mar-09 3:30
memberSimomo23-Mar-09 3:30 
GeneralRe: Error when creating birthday reminder in ASP.NET Pin
Tauiqr17-Oct-12 22:03
memberTauiqr17-Oct-12 22:03 
QuestionAdding the reminder in a Calendar in Public Folder?? Pin
Rahul Vac26-Mar-07 23:27
memberRahul Vac26-Mar-07 23:27 
QuestionRegarding to creating Birthday Reminder Pin
Thimani12-Feb-07 18:27
memberThimani12-Feb-07 18:27 
GeneralSolution if you get error 80004005 Pin
KirbzStar28-Nov-06 14:56
memberKirbzStar28-Nov-06 14:56 
GeneralLogon without Outlook Running Pin
mtbbiker3-Oct-05 1:35
membermtbbiker3-Oct-05 1:35 
Questionversion independent ? Pin
fracalifa31-Mar-05 23:50
memberfracalifa31-Mar-05 23:50 
Hello csharper's,

I have two questions.

1)
does the program also run when I'm referencing to Office 9-DLL'S (XP) and the customer uses older versions of Outlook (2000)

and

2)
Is there a simple solution to check if Outlook is already installed (whithout using exception handling)

Thank You
Frank

PS.: The code is no rocket science .... but usefull.

GeneralError Outlook unrecoqnized Pin
chikku8-Mar-04 22:28
susschikku8-Mar-04 22:28 
GeneralRe: Error Outlook unrecoqnized Pin
partyganger8-Mar-04 23:56
memberpartyganger8-Mar-04 23:56 
GeneralRe: Error Outlook unrecoqnized Pin
NITH30-Apr-04 3:35
memberNITH30-Apr-04 3:35 
GeneralError Outlook unrecoqnized Pin
chikku8-Mar-04 22:27
memberchikku8-Mar-04 22:27 
QuestionAnyone ported this to C#? Pin
dragomir3-Feb-04 0:02
memberdragomir3-Feb-04 0:02 
AnswerRe: Anyone ported this to C#? Pin
NITH30-Apr-04 3:27
memberNITH30-Apr-04 3:27 
QuestionCreate a message rule? Pin
dragomir22-Jan-04 22:33
memberdragomir22-Jan-04 22:33 
AnswerRe: Create a message rule? Pin
Frank Eden26-Jan-04 11:50
memberFrank Eden26-Jan-04 11:50 
GeneralSending Outlook items Pin
Anonymous13-Jan-04 1:30
sussAnonymous13-Jan-04 1:30 
GeneralRe: Sending Outlook items Pin
Frank Eden13-Jan-04 10:59
memberFrank Eden13-Jan-04 10:59 
GeneralExcellent article Pin
Per Søderlind5-Jan-04 21:30
sussPer Søderlind5-Jan-04 21:30 
GeneralRe: Excellent article Pin
NITH30-Apr-04 3:29
memberNITH30-Apr-04 3:29 
GeneralWhats the purpose Pin
super5-Jan-04 18:29
membersuper5-Jan-04 18:29 
GeneralRe: Whats the purpose Pin
Frank Eden5-Jan-04 18:54
memberFrank Eden5-Jan-04 18:54 
GeneralRe: Whats the purpose Pin
gUnOm20-Feb-05 22:49
membergUnOm20-Feb-05 22:49 
GeneralRe: Whats the purpose Pin
Malik Nasir14-May-06 22:55
memberMalik Nasir14-May-06 22:55 
GeneralRe: Whats the purpose Pin
laribum4-Sep-06 2:44
memberlaribum4-Sep-06 2:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150731.1 | Last Updated 5 Jan 2004
Article Copyright 2004 by Frank Eden
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid