Click here to Skip to main content
Licence 
First Posted 4 Jan 2004
Views 80,049
Bookmarked 40 times

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

By Frank Eden | 4 Jan 2004
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.
1 vote, 9.1%
1
2 votes, 18.2%
2

3
4 votes, 36.4%
4
4 votes, 36.4%
5
4.00/5 - 11 votes
1 removed
μ 3.50, σa 2.49 [?]

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

Web Developer

Australia Australia

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.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
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  
Questionversion 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  
QuestionAnyone ported this to C#? Pinmemberdragomir1:02 3 Feb '04  
AnswerRe: Anyone ported this to C#? PinmemberNITH4:27 30 Apr '04  
QuestionCreate a message rule? Pinmemberdragomir23:33 22 Jan '04  
AnswerRe: 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    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.

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