Create an Appointment


Below is the code snippet to create and save an appointment:

   Outlook.AppointmentItem appt = Application.CreateItem(

  Outlook.OlItemType.olAppointmentItem) as Outlook.AppointmentItem;

  appt.Subject = "Developer's Conference";

  appt.AllDayEvent = true;

  appt.Start = DateTime.Parse("6/11/2007 12:00 AM");

  appt.End = DateTime.Parse("6/16/2007 12:00 AM");



Following steps are required to create an appointment and save it in ICS format.

  1. Create an instance of the Appointment class and initialize it with this constructor.
  2. Pass the following arguments in the above constructor
    1. Attendees
    2. Description
    3. End Date
    4. Location
    5. Organizer
    6. Start Date
    7. Summary
  3. Call the Save() method and specify the file name and format in the arguments.

The appointment can be opened in Microsoft Outlook or any program that can load an ICS file. If the file is opened in Microsoft Outlook it automatically adds the appointment in the Outlook calendar.

The following code snippets create and save an appointment to disk in ICS format.

   string location = "Meeting Location: Room 5";

  DateTime startDate = new DateTime(1997, 3, 18, 18, 30, 00),

  endDate = new DateTime(1997, 3, 18, 19, 30, 00);

  MailAddress organizer = new MailAddress("", "Organizer");

  MailAddressCollection attendees = new MailAddressCollection();

  attendees.Add(new MailAddress("", "First attendee"));

  Appointment target = new Appointment(location, startDate, endDate, organizer, attendees);


Download Sample Code

Download Running Code