![]() |
Languages »
C# »
How To
Intermediate
How to Create Birthday Reminders Using Microsoft Outlook, in C#By Frank EdenThis 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
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
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.
Outlook._Application olApp =
(Outlook._Application) new Outlook.Application();
Outlook.NameSpace mapiNS = olApp.GetNamespace("MAPI")
string profile = "";
mapiNS.Logon(profile, null, null, null);
CreateYearlyAppointment(olApp, "Birthday",
"Kim", new DateTime(2004, 03,08, 7, 0, 0));
for your wife and kids etc. etc.!!!
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();
}
With a one week reminder, you will never again forget your Mum's birthday.
General
News
Question
Answer
Joke
Rant
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 Web16 | Advertise on the Code Project |