EWS与其他自定义属性交换创建约会 [英] EWS Create Appointment in exchange with extra custom properties

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

问题描述

我目前正在寻找一种方法,可以使用C#将一些额外的属性保存到交换约会中.目前,我可以使用以下属性进行保存:

Im currently looking at a way to save a few extra properties to an exchange appointment using C#. Currently I can save using the following properties:

Appointment calendar = new Appointment(p_service);

calendar.Subject = calendarS5Subject;
calendar.Body = calendarS5Body;
calendar.Start = calendarS5StartDateTime;
calendar.End = calendarS5EndDateTime;
calendar.IsReminderSet = false;
calendar.Location = calendarS5Location;
calendar.Body.BodyType = BodyType.Text;

calendar.Save();

但是,我希望能够存储自己的自定义属性,例如calendar.EventIDcalendar.Blah.是否可以根据约会保存这些属性,然后以后再访问它们?如果所有这些都可以作为用户控件表单存储在指定窗口中,那就更好了.我知道您可以使用类型为 AppointmentItem 的Outlook加载项来执行此操作.但是,我还没有找到一种方法来与约会类型的交流.

However I want to be able to store my own custom properties like calendar.EventID and calendar.Blah . Is it possible to save these properties against the appointment and then be able to access them later? It would be even better if it could all be stored as a user control form inside the appoint window. I know you can do this with an outlook addin that uses the type AppointmentItem. However I am yet to find a way to do it with exchange with the type of Appointment.

TIA.

我现在可以使用以下方法保存额外的属性:

I have now been able to save the extra property using:

Guid EventIDSetGUID = new Guid("{C11FF724-AA03-4555-9952-8FA248A11C3E}");
ExtendedPropertyDefinition extendedPropertyEventID = new ExtendedPropertyDefinition(EventIDSetGUID, "EventID", MapiPropertyType.String);
calendar.SetExtendedProperty(extendedPropertyEventID, calendarS5EventID);

但是,我现在正努力重新读取该属性.保存完额外属性后,这项工作就可以了,但是如果我重新启动应用程序,然后尝试读取额外属性,则eventIDProp总是返回null.我的阅读代码:

However I am now struggling to read back that property later on. This work right after I have saved the extra property but if I restart the application and then try to read the extra property eventIDProp always returns null. My code for reading:

Guid EventIDReadGUID = new Guid("{C11FF724-AA03-4555-9952-8FA248A11C3E}");
ExtendedPropertyDefinition extendedPropertyEventIDRead = new ExtendedPropertyDefinition(EventIDReadGUID, "EventID", MapiPropertyType.String);
object eventIDProp;
if (calendar.TryGetProperty(extendedPropertyEventIDRead, out eventIDProp) && eventIDProp != calendarS5EventID)
{

}

推荐答案

您可以使用MAPI扩展属性来做到这一点:

You can do that with MAPI extended properties:

    // Define MAPI extended properties
    private readonly ExtendedPropertyDefinition _extendedPropEventId = 
        new ExtendedPropertyDefinition(
            new Guid("{00020329-0000-0000-C000-000000000046}"),
            "Event Identifier",
            MapiPropertyType.String);

    private readonly ExtendedPropertyDefinition _extendedPropBlah = 
        new ExtendedPropertyDefinition(
            new Guid("{00020329-0000-0000-C000-000000000046}"),
            "Blah",
            MapiPropertyType.String);

...

    // Set extended properties for appointment
    calendar.SetExtendedProperty(_extendedPropEventId, "custom EventID value");
    calendar.SetExtendedProperty(_extendedPropBlah, "custom Blah value");

...

    // Bind to existing item for reading extended properties
    var propertySet = new PropertySet(BasePropertySet.FirstClassProperties, _extendedPropEventId, _extendedPropBlah);
    var calendar = Appointment.Bind(p_service, itemId, propertySet);
    if (calendar.ExtendedProperties.Any(ep => ep.PropertyDefinition.PropertySetId == _extendedPropEventId.PropertySetId))
    {
        // Add your code here...
    }

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

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