More Outlook Resource Sites

Microsoft Developer Network (MSDN)

FAQs and other general resources

share code 23-May-2019 09:49

Looking for help with Outlook programming projects — VSTO, add-ins, VBA, custom Outlook forms, etc.? You′ve come to the right place!

NEW! >> Subscribe to this site via RSS. For more RSS options, see the complete list of feeds on our main news page.

Code level: beginner    Code area: Outlook and .NET Printer Friendly Version
Title: Creating Outlook appointments with C#
Description: Creating Outlook appointments with C#
Date: 22-Feb-2005  07:36
Code level: beginner
Code area: Outlook and .NET
Posted by: Peter Jaušovec
This message is displayed as VB.NET
 //First thing you need to do is add a reference to Microsoft Outlook 11.0 Object Library. Then, create new instance of Outlook.Application object: 

Outlook.Application outlookApp = new Outlook.Application (); 

//Next, create an instance of AppointmentItem object and set the properties: 

Outlook.AppointmentItem oAppointment = (Outlook.AppointmentItem) outlookApp.CreateItem (Outlook.OlItemType.olAppointmentItem);

oAppointment.Subject = "This is the subject for my appointment"; 
oAppointment.Body = "This is the body text for my appointment"; 
oAppointment.Location = "Appointment location"; 

// Set the start date
oAppointment.Start = Convert.ToDateTime ("10/10/2004 10:00:00 AM");
// End date 
oAppointment.End = Convert.ToDateTime ("10/10/2004 2:00:00 PM");
// Set the reminder 15 minutes before start
oAppointment.ReminderSet = true; 
oAppointment.ReminderMinutesBeforeStart = 15; 

//Setting the sound file for a reminder: 
set ReminderPlaySound = true 
//set ReminderSoundFile to a filename. 

//Setting the importance: 
//use OlImportance enum to set the importance to low, medium or high

oAppointment.Importance = Outlook.OlImportance.olImportanceHigh; 

/* OlBusyStatus is enum with following values:
oAppointment.BusyStatus = Outlook.OlBusyStatus.olBusy; 

//Finally, save the appointment: 

// Save the appointment
oAppointment.Save (); 

// When you call the Save () method, the appointment is saved in Outlook. Another useful method is ForwardAsVcal () which can be used to send the Vcs file via email. 

Outlook.MailItem mailItem = oAppointment.ForwardAsVcal (); 
mailItem.To = "recipients email address"; 
mailItem.Send ();
All 59comments
Page [ 1 2 3 4 5 6 Next >>  
  15-Mar-2005  18:26   
Problems I found...

Replaced Outlook with Microsoft.Office.Interop.Outlook
(Outlook didn't resolve with using Microsoft.Office.Interop for some reason)

HTML included in the code by accident

set ReminderPlaySound = true
should be
oAppointment.ReminderPlaySound = true;

  13-Apr-2005  05:51   
This is great you can easily add an appointment but it doesnt check for conflicts whats the isconflict method for?

I have hundreds of appointments in 1 day and there is only 1 of me... yes only
  13-Apr-2005  08:02   
jitu, IsConflict is a method to detect whether two users saved changes to the same item at the same time. It is not a method for checking whether there is a conflicting appointment during a particular time period. To check for existing appointments in a certain time period, you can use the MAPIFolder.Items.FInd method and specify a date/time range in the search string. See
  12-May-2005  02:05   
How do i sent the appointment to someones and save in thier calendar.
  27-Jun-2005  04:10   
I would like to know if it is possible to create a C# .NET application to connect to an Exchange Server account and manipulate appointment items, using Interop.Outlook. All the examples I've found use something like:

Outlook.Application oApp = new Outloook.ApplicationClass();

which opens my local Outlook account. I wonder if there is a way to open a remote account (by passing an address, for instance)? The same question with MAPI.

For now I figured out some solution with CDO and WebDAV, but as I'm doing a research on this subject I would like to have a wide range of possibilities.

Thanks in advance for your support!

Ricardo Pinto

Ps: I would be joyfull if you provide me some code examples :D
  28-Jul-2005  08:46   
Naku, to create an appointment in someone else's calendar, use the Namespace.GetSharedDefaultFolder method to return the folder, then MAPIFolder.Items.Add.
  28-Jul-2005  08:48   
Richardo, if you want to go through Outlook, you can get another mailbox's default Calendar folder with Namespace.GetSharedDefaultFolder. For non-default folders, ,you can only work with calendars for mailboxes visible in the Folder List, by walking the folder hierarchy starting at Namespace.Folders.
  25-Oct-2005  01:21   
I am not able to create the object for OutLook. Application
  26-Oct-2005  14:02   
Ravi, some anti-virus programs block access to New Outlook.Application and CreateObject("Outlook.Application").
  09-Dec-2005  09:51   
Hello, I'm new to programming Outlook related code and I would like to know if it's possible to create a program that sends an appointment (by e-mail) to another user who isn't sharing their calendar. If so, how would this be programmed?
Page [ 1 2 3 4 5 6 Next >>