2

I have created and sent a appointment using following link

My code:

Microsoft.Office.Interop.Outlook.Application app = null;
Microsoft.Office.Interop.Outlook.AppointmentItem appt = null;

app = new Microsoft.Office.Interop.Outlook.Application();

appt = (Microsoft.Office.Interop.Outlook.AppointmentItem)app
    .CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);
appt.Subject = "Meeting ";
appt.Body = "Test Appointment body";
appt.Location = "TBD";
appt.Start = Convert.ToDateTime("06/01/2012 05:00:00 PM");
appt.Recipients.Add("sanjay.surendra@mycompany.com");
appt.End = Convert.ToDateTime("06/01/2012 6:00:00 PM");
appt.ReminderSet = true;
appt.ReminderMinutesBeforeStart = 15;
appt.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh;
appt.BusyStatus = Microsoft.Office.Interop.Outlook.OlBusyStatus.olBusy;
appt.Save();
Microsoft.Office.Interop.Outlook.MailItem mailItem = appt.ForwardAsVcal();
mailItem.To = "sanjay.surendra@mycompany.com";
mailItem.Send();

Now i want the unique appointment ID which i can handle it in my code. Please advice

Community
  • 1
  • 1
Sanjay Surendra
  • 47
  • 3
  • 11

2 Answers2

2

Are you looking for Appointment.EntryID ?

David Brabant
  • 41,623
  • 16
  • 83
  • 111
1

The Appointment.EntryID is what you are looking for. After an item is Saved or Sent (persisted) the EntryID property is assigned.

// ...
appt.Save();
string entryID = appt.EntryID;
// ...

From MSDN:

A MAPI store provider assigns a unique ID string when an item is created in its store. Therefore, the EntryID property is not set for an Outlook item until it is saved or sent. The Entry ID changes when an item is moved into another store...

SliverNinja - MSFT
  • 31,051
  • 11
  • 110
  • 173