Click here to Skip to main content
5,788,961 members and growing! (20,669 online)
Email Password   helpLost your password?
Languages » C# » How To     Intermediate

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

By Frank Eden

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.
C#.NET 1.0, .NET 1.1, Win2K, WinXP, Win2003, Windows, .NET, Visual Studio, Dev

Posted: 4 Jan 2004
Updated: 4 Jan 2004
Views: 54,571
Bookmarked: 31 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
11 votes for this Article.
Popularity: 3.64 Rating: 3.50 out of 5
1 vote, 9.1%
1
2 votes, 18.2%
2
0 votes, 0.0%
3
4 votes, 36.4%
4
4 votes, 36.4%
5

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Frank Eden


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.

Occupation: Web Developer
Location: Australia Australia

Other popular C# articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 22 of 22 (Total in Forum: 22) (Refresh)FirstPrevNext
QuestionAdding the reminder in a Calendar in Public Folder??memberRahul Vac0:27 27 Mar '07  
QuestionRegarding to creating Birthday RemindermemberThimani19:27 12 Feb '07  
GeneralSolution if you get error 80004005memberKirbzStar15:56 28 Nov '06  
GeneralLogon without Outlook Runningmembermtbbiker2:35 3 Oct '05  
Generalversion independent ?memberfracalifa0:50 1 Apr '05  
GeneralError Outlook unrecoqnizedsusschikku23:28 8 Mar '04  
GeneralRe: Error Outlook unrecoqnizedmemberpartyganger0:56 9 Mar '04  
GeneralRe: Error Outlook unrecoqnizedmemberNITH4:35 30 Apr '04  
GeneralError Outlook unrecoqnizedmemberchikku23:27 8 Mar '04  
GeneralAnyone ported this to C#?memberdragomir1:02 3 Feb '04  
GeneralRe: Anyone ported this to C#?memberNITH4:27 30 Apr '04  
GeneralCreate a message rule?memberdragomir23:33 22 Jan '04  
GeneralRe: Create a message rule?memberFrank Eden12:50 26 Jan '04  
GeneralSending Outlook itemssussAnonymous2:30 13 Jan '04  
GeneralRe: Sending Outlook itemsmemberFrank Eden11:59 13 Jan '04  
GeneralExcellent articlesussPer Søderlind22:30 5 Jan '04  
GeneralRe: Excellent articlememberNITH4:29 30 Apr '04  
GeneralWhats the purposemembersuper19:29 5 Jan '04  
GeneralRe: Whats the purposememberFrank Eden19:54 5 Jan '04  
GeneralRe: Whats the purposemembergUnOm23:49 20 Feb '05  
GeneralRe: Whats the purposememberMalik Nasir23:55 14 May '06  
GeneralRe: Whats the purposememberlaribum3:44 4 Sep '06  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 4 Jan 2004
Editor: Smitha Vijayan
Copyright 2004 by Frank Eden
Everything else Copyright © CodeProject, 1999-2009
Web13 | Advertise on the Code Project