none
How to delete attendee's appointment from calendar? RRS feed

  • Question

  • Hi All,

    I need to totally delete meeting from organizer and attendee's calendars with EWS Managed API 1.2. What I do now:

    var exApp = Microsoft.Exchange.WebServices.Data.Appointment.Bind(service, organizer.Id);
    if(exApp.IsMeeting)
    {
       exApp.Delete(Microsoft.Exchange.WebServices.Data.DeleteMode.HardDelete, Microsoft.Exchange.WebServices.Data.SendCancellationsMode.SendToNone);                        
                            for (int i = 0; i < exApp.RequiredAttendees.Count; ++i)
                            {
                                var reqApp = GetAttendeeAppointment(exApp, exApp.RequiredAttendees[i].Address);
                                try
                                {
                                    reqApp.Delete(Microsoft.Exchange.WebServices.Data.DeleteMode.HardDelete);
                                }
                                catch (Exception ex)
                                {
                                    _logger.LogError(ex.Message);                             
                                }
                            }
    }

    And it deletes both items: from organizer and attendee mailboxes, BUT after a while (or after press check messages button) attendee gets message in his Inbox folder with meeting invitation from organizer and item created in calendar again! Why exchange behavior is so strange? I have deleted items first from organizer calendar and then from attendee's, but meeting invitation has been sent by Exchange after while. What I do wrong? How to correctly and totally delete meeting from calendar folder of organizer and attendees? If you could, please post some code.

    Thanx in advance



    Monday, October 15, 2012 10:58 AM

Answers

  • Some sounds a little off in your logic

    1. Meeting created, meeting invitation sent to participant Inbox folder.

      At this stage has the participant Accepted the Meeting Response? or are you doing this on their behalf ? Once a meeting is accepted the Invitation should be removed from the Inbox of the attendee. If you deleted the Appointment before a user has the opportunity to accept the Invitation that invitation won't be deleted it would just create an orphaned meeting, OWA will tentatively add meetings to users calendar based on the Invites in their Inbox. You can turn this off in OWA by unchecking the "Process requests and responses on arrival" in Options-Setting-Calendar.(OWA also uses Ajax so it cache's items as well) . If you want to cater for that type of scenario you may want to add some code to check the Inbox for any Meeting Invites with that particular MeetingId. If everything is happening in a short amount of time eg your creates and deletes then it could just be normal behaviour throwing false positives.

    Cheers
    Glen

    Wednesday, October 17, 2012 5:57 AM
  • You can use the CleanGlobalObjectId and do a search eg

            newAppointment.Save();
            newAppointment.RequiredAttendees.Add("user@domain.com");
            newAppointment.Update(ConflictResolutionMode.AlwaysOverwrite ,SendInvitationsOrCancellationsMode.SendOnlyToAll);
            ExtendedPropertyDefinition CleanGlobalObjectId = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Meeting, 0x3, MapiPropertyType.Binary);
            PropertySet psPropSet = new PropertySet(BasePropertySet.FirstClassProperties);
            psPropSet.Add(CleanGlobalObjectId);
            newAppointment.Load(psPropSet);
            object CalIdVal = null;
            newAppointment.TryGetProperty(CleanGlobalObjectId, out CalIdVal);
            Folder AtndInbox = Folder.Bind(service, new FolderId(WellKnownFolderName.Inbox, "user@domain.com"));
            SearchFilter sfSearchFilter = new SearchFilter.IsEqualTo(CleanGlobalObjectId, Convert.ToBase64String((Byte[])CalIdVal));
            ItemView ivItemView = new ItemView(1);
            FindItemsResults<Item> fiResults = AtndInbox.FindItems(sfSearchFilter, ivItemView);
            if (fiResults.Items.Count > 0) {
                fiResults.Items[0].Delete(DeleteMode.HardDelete);
            }
    Cheers
    Glen
    Thursday, October 18, 2012 6:04 AM

All replies

  • When you call

    reqApp.Delete(Microsoft.Exchange.WebServices.Data.DeleteMode.HardDelete);

    In the attendees mailbox have you tried using the overload with the SendCancellationsMode set to None ?

    I can't see anything wrong with what your doing other then this, you could have a look at Message Tracking on the server to see where its being generated (eg is it coming from the Organizer, do they have any Mobile devices configured etc). Is the invitation message that is generated stored in the SentItems folder of the Organizer that might offer more insight in how it was being generated.

    Cheers
    Glen

    Tuesday, October 16, 2012 5:56 AM
  • When you call

    reqApp.Delete(Microsoft.Exchange.WebServices.Data.DeleteMode.HardDelete);

    In the attendees mailbox have you tried using the overload with the SendCancellationsMode set to None ?

    I can't see anything wrong with what your doing other then this, you could have a look at Message Tracking on the server to see where its being generated (eg is it coming from the Organizer, do they have any Mobile devices configured etc). Is the invitation message that is generated stored in the SentItems folder of the Organizer that might offer more insight in how it was being generated.

    Cheers
    Glen

    Hi Glen,

    I've tried to use overloaded version of Delete with SendCancellationsMode to None. And I thought trouble fixed, until I made log out/log in for participant account. So what is going on detailed:

    1. Meeting created, meeting invitation sent to participant Inbox folder.

    2. With code above I delete organizer item, then participant item. All fine. There no messages any more from organizer to participant.

    3. All this time in OWA I have opened participant calendar. Now in participant calendar meeting item deleted, but meeting invitation still present in Inbox folder. In organizer sent items folder only one item: meeting invitation that was sent to participant when meeting was created. All fine. When I press check messages button in participant account from OWA, I get nothing. So it seems all working now.

    4. Then I log out from OWA participant's account and log-in again. And alas, I see item re-created in participant calendar again?! At the same time with Outlook 2007 for instance this trick doesn't work.

    5. Only way to delete calendar item forever (regarding to OWA) is to delete this invitation from participant Inbox. If so, how can I do this from managed API? How to find meeting invitation based on participant/organizer meeting item id?

    P.S. I made some test and the result is: everytime OWA re-creates meeting in participant calendar in case if participant has corresponding meeting invitation in his Inbox folder. This behavior is different in Outlook 2007/2010

    Tuesday, October 16, 2012 8:34 AM
  • Some sounds a little off in your logic

    1. Meeting created, meeting invitation sent to participant Inbox folder.

      At this stage has the participant Accepted the Meeting Response? or are you doing this on their behalf ? Once a meeting is accepted the Invitation should be removed from the Inbox of the attendee. If you deleted the Appointment before a user has the opportunity to accept the Invitation that invitation won't be deleted it would just create an orphaned meeting, OWA will tentatively add meetings to users calendar based on the Invites in their Inbox. You can turn this off in OWA by unchecking the "Process requests and responses on arrival" in Options-Setting-Calendar.(OWA also uses Ajax so it cache's items as well) . If you want to cater for that type of scenario you may want to add some code to check the Inbox for any Meeting Invites with that particular MeetingId. If everything is happening in a short amount of time eg your creates and deletes then it could just be normal behaviour throwing false positives.

    Cheers
    Glen

    Wednesday, October 17, 2012 5:57 AM
  • Hi Glen,

    Participant do not answer to meeting invitation in my case. And can you give me an example of code where I can find invite in inbox folder of participant based on meeting id?

    Thanx in advance

    Wednesday, October 17, 2012 6:44 AM
  • You can use the CleanGlobalObjectId and do a search eg

            newAppointment.Save();
            newAppointment.RequiredAttendees.Add("user@domain.com");
            newAppointment.Update(ConflictResolutionMode.AlwaysOverwrite ,SendInvitationsOrCancellationsMode.SendOnlyToAll);
            ExtendedPropertyDefinition CleanGlobalObjectId = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Meeting, 0x3, MapiPropertyType.Binary);
            PropertySet psPropSet = new PropertySet(BasePropertySet.FirstClassProperties);
            psPropSet.Add(CleanGlobalObjectId);
            newAppointment.Load(psPropSet);
            object CalIdVal = null;
            newAppointment.TryGetProperty(CleanGlobalObjectId, out CalIdVal);
            Folder AtndInbox = Folder.Bind(service, new FolderId(WellKnownFolderName.Inbox, "user@domain.com"));
            SearchFilter sfSearchFilter = new SearchFilter.IsEqualTo(CleanGlobalObjectId, Convert.ToBase64String((Byte[])CalIdVal));
            ItemView ivItemView = new ItemView(1);
            FindItemsResults<Item> fiResults = AtndInbox.FindItems(sfSearchFilter, ivItemView);
            if (fiResults.Items.Count > 0) {
                fiResults.Items[0].Delete(DeleteMode.HardDelete);
            }
    Cheers
    Glen
    Thursday, October 18, 2012 6:04 AM