Sanjay Surendra
Sanjay Surendra

Reputation: 47

Get Appointment ID after sending an Appointment

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("[email protected]");
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 = "[email protected]";
mailItem.Send();

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

Upvotes: 2

Views: 2530

Answers (2)

SliverNinja - MSFT
SliverNinja - MSFT

Reputation: 31651

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...

Upvotes: 1

David Brabant
David Brabant

Reputation: 43539

Are you looking for Appointment.EntryID ?

Upvotes: 2

Related Questions