Click here to Skip to main content
Click here to Skip to main content

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

, 4 Jan 2004 CPOL
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.

Comments and Discussions

 
GeneralError when creating birthday reminder in ASP.NET PinmemberSimomo23-Mar-09 4:30 
GeneralRe: Error when creating birthday reminder in ASP.NET PinmemberTauiqr17-Oct-12 23:03 
QuestionAdding the reminder in a Calendar in Public Folder?? PinmemberRahul Vac27-Mar-07 0:27 
QuestionRegarding to creating Birthday Reminder PinmemberThimani12-Feb-07 19:27 
GeneralSolution if you get error 80004005 PinmemberKirbzStar28-Nov-06 15:56 
GeneralLogon without Outlook Running Pinmembermtbbiker3-Oct-05 2:35 
Questionversion independent ? Pinmemberfracalifa1-Apr-05 0: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 Pinsusschikku8-Mar-04 23:28 
GeneralRe: Error Outlook unrecoqnized Pinmemberpartyganger9-Mar-04 0:56 
GeneralRe: Error Outlook unrecoqnized PinmemberNITH30-Apr-04 4:35 
GeneralError Outlook unrecoqnized Pinmemberchikku8-Mar-04 23:27 
QuestionAnyone ported this to C#? Pinmemberdragomir3-Feb-04 1:02 
AnswerRe: Anyone ported this to C#? PinmemberNITH30-Apr-04 4:27 
QuestionCreate a message rule? Pinmemberdragomir22-Jan-04 23:33 
AnswerRe: Create a message rule? PinmemberFrank Eden26-Jan-04 12:50 
GeneralSending Outlook items PinsussAnonymous13-Jan-04 2:30 
GeneralRe: Sending Outlook items PinmemberFrank Eden13-Jan-04 11:59 
GeneralExcellent article PinsussPer Søderlind5-Jan-04 22:30 
GeneralRe: Excellent article PinmemberNITH30-Apr-04 4:29 
GeneralWhats the purpose Pinmembersuper5-Jan-04 19:29 
GeneralRe: Whats the purpose PinmemberFrank Eden5-Jan-04 19:54 
GeneralRe: Whats the purpose PinmembergUnOm20-Feb-05 23:49 
GeneralRe: Whats the purpose PinmemberMalik Nasir14-May-06 23:55 
GeneralRe: Whats the purpose Pinmemberlaribum4-Sep-06 3: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
Web01 | 2.8.141223.1 | Last Updated 5 Jan 2004
Article Copyright 2004 by Frank Eden
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid