none
entry id and deleted appointment RRS feed

  • Question

  • i have an entry id of a deleted appointment.

    how can i check if the entry id belongs to deleted appointment or existing appointment?

    the folloing code bring me the deleted appointment: (but in the end if it the event is not in the calendar again..)

    Microsoft.Office.Interop.Outlook.Application outlookApp = null; 
    Microsoft.Office.Interop.Outlook.NameSpace mapiNamespace = null; 
    Microsoft.Office.Interop.Outlook.MAPIFolder CalendarFolder = null; 
    Microsoft.Office.Interop.Outlook.Items outlookCalendarItems = null;
    Microsoft.Office.Interop.Outlook.AppointmentItem appItem = null;
    outlookApp = new Microsoft.Office.Interop.Outlook.Application(); 
    mapiNamespace = outlookApp.GetNamespace("MAPI"); 
     
    CalendarFolder = mapiNamespace.GetDefaultFolder(OlDefaultFolders.olFolderCalendar); 
    string StoreId = CalendarFolder.Store.StoreID;
    string id = "00000000997475591B0F494DBD7243876D2DA918C4792400";
    appItem = mapiNamespace.GetItemFromID(id, StoreId);
    appItem.Subject = "Shiran";
    appItem.Save();

    Thursday, August 16, 2012 1:33 PM

Answers

  • AppointmentItem.Parent will return the parent folder (MAPIFolder). If it is Deleted Items, you know it was deleted.

    Sorry, I forgot that Outlook won't let you search on binary fields. the querty below won't work:

    set Appt = Folder.Items.Find("[GlobalAppointmentID] = '" & SampleApptId & "'")

    You can either loop through all items in the folder looking for a match (extermely inefficient) or use Redemption (which does support searching on binary properties):

    SampleApptId = "040000008200E00074C5B7101A82E00800000000C0BF8794BD7CCD0100000000000000001000000029BFB0C3E58B33468DED5A4D087CF211"
    set Session = CreateObject("Redemption.RDOSession")
    Session.MAPIOBJECT = Application.Session.MAPIOBJECT
    set Folder = Session.GetDefaultFolder(olFolderCalendar)
    set Appt = Folder.Items.Find("GlobalAppointmentID = '" & SampleApptId & "'")
    if Appt Is Nothing Then
      MsgBox "Appointment was not found"
    Else
      MsgBox "Found appointment: " & Appt.Subject
    End If


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Sunday, August 19, 2012 4:52 PM

All replies

  • try checking MeetingStatus
    Thursday, August 16, 2012 1:47 PM
  • the MeetingStatus stay the same..
    Thursday, August 16, 2012 2:05 PM
  • is this an appointment or meeting? (meeting has participants)
    Thursday, August 16, 2012 2:22 PM
  •  an appointment
    Thursday, August 16, 2012 2:23 PM
  • If the appointment is deleted, GetItemfromID will fail. Unless of course you are using a PST store, which does not change the entry id when an item is moved to the Deleted Items folder. In that case you need to check the Parent property.

    Also keep in mind that when a meeting update is received, Outlook will recreate the appointment and GetItemfromID will also fail. You really need to use the appointment id (GlobalAppointmentID property) and MAPIFolder.Items.Find().


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!


    Thursday, August 16, 2012 2:26 PM
  • and you are able to get access to deleted appointment? i thought you would get COMException that item no longer exists...
    Thursday, August 16, 2012 2:29 PM
  • How can i use the GlobalAppointmentID and MAPIFolder.Items.Find()?

    can't resolve my problem yet...

    you said somthing about parent property? what can i check with the parent?

    • Edited by redgolda Sunday, August 19, 2012 6:26 AM
    Sunday, August 19, 2012 6:10 AM
  • AppointmentItem.Parent will return the parent folder (MAPIFolder). If it is Deleted Items, you know it was deleted.

    Sorry, I forgot that Outlook won't let you search on binary fields. the querty below won't work:

    set Appt = Folder.Items.Find("[GlobalAppointmentID] = '" & SampleApptId & "'")

    You can either loop through all items in the folder looking for a match (extermely inefficient) or use Redemption (which does support searching on binary properties):

    SampleApptId = "040000008200E00074C5B7101A82E00800000000C0BF8794BD7CCD0100000000000000001000000029BFB0C3E58B33468DED5A4D087CF211"
    set Session = CreateObject("Redemption.RDOSession")
    Session.MAPIOBJECT = Application.Session.MAPIOBJECT
    set Folder = Session.GetDefaultFolder(olFolderCalendar)
    set Appt = Folder.Items.Find("GlobalAppointmentID = '" & SampleApptId & "'")
    if Appt Is Nothing Then
      MsgBox "Appointment was not found"
    Else
      MsgBox "Found appointment: " & Appt.Subject
    End If


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Sunday, August 19, 2012 4:52 PM