Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

EWS API- Differences in ICalUid returned when appointments are created by Office 365 account vs. Microsoft Outlook Mac Client

$
0
0

Hi, 

Please help, this is very strange behavior I have come across:

Following is the issue:

1. I used Office365 cloud account to test this before. Whenever, scheduled appointments are retrieved from an account using EWS Api, it returns ICalUid of an appointment in the following

format: 040000008200E00074C5B7101A82E0080000000074BADF021787CF01000000000000000010000000A5805E16A0F892419C4ABE270A4EEBC7

2. Today, I used the same account through Microsoft Outlook Client on Mac, and created few appointments in a calendar. The same EWS Api call, gives Appointments back with different format of ICalUid:

For example: 7D9B63D2-74BD-4317-A083-DFE6C2BFC1B4

The reason, its bothers because of the following I am trying to achieve:

- I have a service account whose calendar is queried for appointments created in particular time interval. For example- for 2 days.

- The Query FindAppointments returns all events in the start and end time. Single appointments are returned once, where recurring events are returned as all separate instances of that recurring event.

            CalendarFolder calendar = CalendarFolder.Bind(_service, WellKnownFolderName.Calendar, new PropertySet(BasePropertySet.FirstClassProperties));
            CalendarView cv = new CalendarView(start, end);
            cv.MaxItemsReturned = 1000;

            var meetings = new List<Meeting>();

            FindItemsResults<Appointment> masterResults = calendar.FindAppointments(cv);

- Now, in the items returned, "Resources" are returned as empty; if that user is not an organizer of that appointment.

- to get Resources part for that appointment, I need to query organizer's calendar to find out that exact appointment.

To do that, I found following method in online search (on most of the forums), which works fine for type 1. of ICalUid mentioned above; but does not work for type 2. ICalUid mentioned above.

[References:

http://social.msdn.microsoft.com/Forums/en-US/26c2f76d-93bb-4a70-80e8-cf6cc9c66254/search-appointment-by-ical-in-ews-managed?forum=exchangesvrdevelopment

http://stackoverflow.com/questions/3829039/get-the-organizers-calendar-appointment-using-ews-for-exchange-2010

http://www.infinitec.de/post/2009/04/13/Searching-a-meeting-with-a-specific-UID-using-Exchange-Web-Services-2007.aspx

]

Here is my code:

        private string GetObjectIdStringFromUid(string id)
        {
            var buffer = new byte[id.Length / 2];
            for (int i = 0; i < id.Length / 2; i++)
            {
                var hexValue = byte.Parse(id.Substring(i * 2, 2), System.Globalization.NumberStyles.AllowHexSpecifier);
                buffer[i] = hexValue;
            }
            return Convert.ToBase64String(buffer);
        }

// apt passed to this function, is an appointment retrieved from a service account, who is not an organizer of this appointment.

        private Appointment GetAppointmentFromOrganizer(Appointment apt)
        {
            ExchangeService service1 = Impersonate(apt.Organizer.Address.ToLower());

            var filter = new SearchFilter.IsEqualTo
            {
                PropertyDefinition = new ExtendedPropertyDefinition
                    (DefaultExtendedPropertySet.Meeting, 0x03, MapiPropertyType.Binary),
                Value = GetObjectIdStringFromUid(apt.ICalUid) //Hex value converted to byte and base64 encoded
            };
            var view = new ItemView(1) { PropertySet = new PropertySet(BasePropertySet.FirstClassProperties) };

            Appointment item = service1.FindItems(WellKnownFolderName.Calendar, filter, view).Items[0] as Appointment;
            item.Load();
            return item;
        }

- I have tried using Appointment.Id.UniqueId instead of ICalUid to retrieve an event form Organizer's calendar, but it returns empty result.

What exactly is the right way (or filter parameter) to pull out particular appointment from organizer's calendar?

Your help is appreciated.


Viewing all articles
Browse latest Browse all 7132

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>