Click here to Skip to main content
15,880,967 members
Articles / Database Development / SQL Server
Tip/Trick

Setting up an MS Outlook Appointment C#

Rate me:
Please Sign up or sign in to vote.
5.00/5 (13 votes)
28 May 2010CPOL1 min read 87.6K   25   11
This is a simple article describing how to create an add an outlook appointment to your MS Outlook Calender.
Introduction

This is a simple article describing how to create an add an outlook appointment to your MS Outlook Calender.

Using the code
This article has been made as straight forward as possible for you, simple follow the steps (1-7) and in no time you should have the app up and running. You can find a full example (With screen shots for importing reference) included in the download file.

Step 1 - Import the outlook reference

The first thing that you need to do is add a reference to the Microsoft Outlook 12.0 Object Library.

1.1. [Right click] on your [Project solution] – [Click] on [Add reference]

1.2. [Click] on the [COM] tab – Scroll down until you find Microsoft Outlook 12.0

1.3 [Click] OK

Step 2 // Sets up and creates an outlook calender entry
Outlook.Application outlookApp = new Outlook.Application(); // creates new outlook app
Outlook.AppointmentItem oAppointment = (Outlook.AppointmentItem)outlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem); // creates a new appointment


Step 3 // Set appointment settings
oAppointment.Subject = "Enquiry Changes made to " + name + "'s enquiry"; // set the subject
oAppointment.Body = "This is where the appointment body of the appointment is written"; // set the body
oAppointment.Location = "Nicks Desk!"; // set the location
oAppointment.Start = Convert.ToDateTime(notesDate); // Set the start date 
oAppointment.End = Convert.ToDateTime(notesDate); // End date 
oAppointment.ReminderSet = true; // Set the reminder
oAppointment.ReminderMinutesBeforeStart = 15; // reminder time
oAppointment.Importance = Outlook.OlImportance.olImportanceHigh; // appointment importance
oAppointment.BusyStatus = Outlook.OlBusyStatus.olBusy;


Step 4 // save the appointment
oAppointment.Save();


Step 5 - Check your outlook calender

Appointment will now be added to your calender

Step 6 // send the details in email
Outlook.MailItem mailItem = oAppointment.ForwardAsVcal(); 
// email address to send to 
mailItem.To = "mailto:me@decodedsolutions.co.uk">me@decodedsolutions.co.uk; 
// send 
mailItem.Send(); 


Step 7 - Finished

Your appointment will now have been created and added to your outlook calender. An email will have also been sent to the address you specified.

Conclusion

Now that we have created the mailItem, not only will the appointment be added to your calendar, but an email sent to an address of your choice.
This small application is very useful and can save you a lot of time and effort. It is well worth implementing as a standalone app or as an add on to an existing one.

Thanks Nick Austin DecodedSolutions

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Junior) DecodedSolutions.co.uk
United Kingdom United Kingdom
We are software developers and we specialise in all software development.

Visit Decoded Solutions NOW for all your development needs.

Comments and Discussions

 
Questionhow to send calender attachment from specific email to multiple persons Pin
Member 103787677-Nov-18 9:16
Member 103787677-Nov-18 9:16 
QuestionoAppointment Pin
Mike Forscutt18-Aug-15 0:36
Mike Forscutt18-Aug-15 0:36 
Questionreminder is showing none in recipient side Pin
Member 1074369128-Jan-15 21:26
Member 1074369128-Jan-15 21:26 
QuestionPDF Attachment for the appointment created Pin
Sameer_Deakin20-Oct-14 20:27
Sameer_Deakin20-Oct-14 20:27 
QuestionAbout Namesaces Pin
alaa bektash30-Nov-13 0:01
alaa bektash30-Nov-13 0:01 
AnswerRe: About Namesaces Pin
Mike Forscutt18-Aug-15 0:28
Mike Forscutt18-Aug-15 0:28 
Generalabout the final mail sent with appointment Pin
niveditha 200912-Jul-12 10:19
niveditha 200912-Jul-12 10:19 
QuestionI like this, I'm using 14.0 library but this still works Pin
dixbear18-Apr-12 5:06
dixbear18-Apr-12 5:06 
AnswerRe: I like this, I'm using 14.0 library but this still works Pin
niveditha 200912-Jul-12 10:21
niveditha 200912-Jul-12 10:21 
GeneralRe: I like this, I'm using 14.0 library but this still works Pin
zemuss12-Aug-12 9:33
zemuss12-Aug-12 9:33 
GeneralRe: I like this, I'm using 14.0 library but this still works Pin
Member 103787677-Nov-18 9:21
Member 103787677-Nov-18 9:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.