0
votes

I try to add a custom property to created appointments like this:

var newEvent = new Appointment(service)
        {
            Start = start,
            End = end,
            Subject = subject,
            ReminderMinutesBeforeStart = 15
        };
        var extendendProperty = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Address, "organizer",
            MapiPropertyType.String);
        newEvent.SetExtendedProperty(extendendProperty, organizer);

but problem is that when I try get this appointment from server, property ExtendedProperty is empty.

In addition I create new appointment and add 'room' as a required attendee, and when I try get this appointment, I don't get it from my calendar but from room calendar.

So, I want to add extend property to my appointment and invite 'room'. Next get all appointments of the room and here I want read this property. It is even possible?

I read this topic: EWS Create Appointment in exchange with extra custom properties and as I understand I'll must have access to ExtendendPropertyDefinition when I want read this property, and must known id of this appointment before. Now I download all appointments from outlook by this code:

var folderId = new FolderId(WellKnownFolderName.Calendar, new Mailbox(userName));
        var calendar = CalendarFolder.Bind(service, folderId, new PropertySet());
        return calendar.FindAppointments(new CalendarView(start, stop)).ToList();

EDIT

Thanks Glen Scales! It almost works as I want, but one thing. I can read this additional property if I download my own appointments, but in that code I download appointments from room calendar.

As I suppose when creating new appointment and add room as required attendant, it create his own appointment and this additional property isn't copied.

So is any way to get this additional property from room appointment, when I add this property to my?

1

1 Answers

1
votes

You need to first Create a property set, add the extended property you want to load to that property set. Then tell EWS you want that property returned when you execute the FindAppointment method see https://msdn.microsoft.com/en-us/library/office/dd633697(v=exchg.80).aspx eg in your example

        PropertySet YourProperyset = new PropertySet(BasePropertySet.FirstClassProperties);
        var extendendProperty = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Address, "organizer",MapiPropertyType.String);
        YourProperyset.Add(extendendProperty);
        var folderId = new FolderId(WellKnownFolderName.Calendar, new Mailbox(userName));
        var calendar = CalendarFolder.Bind(service, folderId);
        var calendarView = new CalendarView(start, stop);
        calendarView.PropertySet = YourProperyset;
        return calendar.FindAppointments(calendarView).ToList();