Create appointment with custom properties in EWS

假装没事ソ 提交于 2019-12-02 17:16:10

问题


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:


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();


来源:https://stackoverflow.com/questions/32377838/create-appointment-with-custom-properties-in-ews

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!