Click here to Skip to main content
6,293,171 members and growing! (11,638 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, Visual Studio, Dev
Posted:4 Jan 2004
Views:59,818
Bookmarked:34 times
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
11 votes for this article.
Popularity: 3.64 Rating: 3.50 out of 5
1 vote, 9.1%
1
2 votes, 18.2%
2

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


Member
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
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 23 of 23 (Total in Forum: 23) (Refresh)FirstPrevNext
GeneralError when creating birthday reminder in ASP.NET PinmemberSimomo4:30 23 Mar '09  
QuestionAdding the reminder in a Calendar in Public Folder?? PinmemberRahul Vac0:27 27 Mar '07  
QuestionRegarding to creating Birthday Reminder PinmemberThimani19:27 12 Feb '07  
GeneralSolution if you get error 80004005 PinmemberKirbzStar15:56 28 Nov '06  
GeneralLogon without Outlook Running Pinmembermtbbiker2:35 3 Oct '05  
Generalversion independent ? Pinmemberfracalifa0:50 1 Apr '05  
GeneralError Outlook unrecoqnized Pinsusschikku23:28 8 Mar '04  
GeneralRe: Error Outlook unrecoqnized Pinmemberpartyganger0:56 9 Mar '04  
GeneralRe: Error Outlook unrecoqnized PinmemberNITH4:35 30 Apr '04  
GeneralError Outlook unrecoqnized Pinmemberchikku23:27 8 Mar '04  
GeneralAnyone ported this to C#? Pinmemberdragomir1:02 3 Feb '04  
GeneralRe: Anyone ported this to C#? PinmemberNITH4:27 30 Apr '04  
GeneralCreate a message rule? Pinmemberdragomir23:33 22 Jan '04  
GeneralRe: Create a message rule? PinmemberFrank Eden12:50 26 Jan '04  
GeneralSending Outlook items PinsussAnonymous2:30 13 Jan '04  
GeneralRe: Sending Outlook items PinmemberFrank Eden11:59 13 Jan '04  
GeneralExcellent article PinsussPer Søderlind22:30 5 Jan '04  
GeneralRe: Excellent article PinmemberNITH4:29 30 Apr '04  
GeneralWhats the purpose Pinmembersuper19:29 5 Jan '04  
GeneralRe: Whats the purpose PinmemberFrank Eden19:54 5 Jan '04  
GeneralRe: Whats the purpose PinmembergUnOm23:49 20 Feb '05  
GeneralRe: Whats the purpose PinmemberMalik Nasir23:55 14 May '06  
GeneralRe: Whats the purpose Pinmemberlaribum3: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
Web15 | Advertise on the Code Project