在EWS中使用自定义属性创建约会 [英] Create appointment with custom properties in EWS

查看:91
本文介绍了在EWS中使用自定义属性创建约会的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试向创建的约会中添加自定义属性,如下所示:

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

但是问题是,当我尝试从服务器获取此约会时,属性ExtendedProperty为空.

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?

我阅读了以下主题: EWS创建约会以与额外的自定义属性,据我了解,当我要读取此属性时,我必须有权访问ExtendendPropertyDefinition,并且必须在此之前知道此约会的ID.现在,我通过此代码从Outlook下载所有约会:

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

编辑

感谢格伦尺度! 它几乎可以按我想要的方式工作,但有一件事.如果我下载自己的约会,则可以阅读此附加属性,但是在该代码中,我从会议室日历中下载约会.

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?

推荐答案

您需要先创建一个属性集,然后将要加载的扩展属性添加到该属性集.然后告诉EWS您希望在执行FindAppointment方法时返回该属性,请参见 https://msdn.microsoft.com/en-us/library/office/dd633697(v = exchg.80).aspx 例如在您的示例中

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

这篇关于在EWS中使用自定义属性创建约会的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆