Exchange Webservice托管API-通过扩展属性查找项目 [英] Exchange Webservice Managed API - Find items by extended properties

查看:63
本文介绍了Exchange Webservice托管API-通过扩展属性查找项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试对EWS约会使用扩展属性,但似乎无法再次找到约会. set属性部分等于此问题中显示的部分:

I have tried to use extended properties on appointments with EWS, but I can not seem to find the appointments again. The set property part is equal to the one shown in this question:

当我尝试检索约会时,我遵循了以下示例:

When I try to retrieve the appointment, I have followed these examples:

http://msdn.microsoft.com/en-us/uc14trainingcourse_5l_topic3#_Toc254008129 http://msdn.microsoft.com /en-us/library/exchange/dd633697(v=exchg.80).aspx

但是我进行查询时从未得到任何约会.

But I never get any appointments returned when I make a lookup.

以下是查找代码:

        ItemView view = new ItemView(10);

        // Get the GUID for the property set.
        Guid MyPropertySetId = new Guid("{" + cGuid + "}");

        // Create a definition for the extended property.
        ExtendedPropertyDefinition extendedPropertyDefinition =
          new ExtendedPropertyDefinition(MyPropertySetId, "AppointmentID", MapiPropertyType.String);

        view.PropertySet =
         new PropertySet(
               BasePropertySet.IdOnly,
               ItemSchema.Subject,
               AppointmentSchema.Start,
               AppointmentSchema.End, extendedPropertyDefinition);

        SearchFilter filter = new SearchFilter.Exists(extendedPropertyDefinition);

        FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, filter,
            view);

非常感谢您的帮助.

修改: 当我尝试创建该属性时,如文档所示:

When I try to create the property like the documentation shows:

http://msdn. microsoft.com/en-us/library/exchange/dd633654(v=exchg.80).aspx

它失败了,因为它添加了Guid作为属性值. :-/

It fails because its a Guid im adding as property value. :-/

再次 刚刚尝试获取今天的所有约会,并从我刚刚创建的约会中获取属性,它的内容与我存储的内容相同,但没有{},因此必须与过滤器配合使用.

Edit again: Just tried getting all appointments for today, and getting the property from the appointment I just created, and it says the same as I stored, without the {}, so it must be somthing with the filter.

再次编辑*

 ExtendedPropertyDefinition extendedProperty = new ExtendedPropertyDefinition(

如果我使用:

 new ExtendedPropertyDefinition(
                DefaultExtendedPropertySet.Appointment,
                "AppointmentID",
                MapiPropertyType.String);

它会找到具有属性的所有约会,但是如果我搜索特定约会:

It finds all the appointments with properties, but if I search for a specific one:

 Guid MyPropertySetId = new Guid("{" + cGuid + "}");

 ExtendedPropertyDefinition extendedProperty =
            new ExtendedPropertyDefinition(
                MyPropertySetId,
                "AppointmentID",
                MapiPropertyType.String);

然后什么也没找到.

推荐答案

下面是一个示例代码,该示例代码如何创建带有customid的约会并在保存后找到它:

here's a samplecode how to create an appointment with the customid and find it after saving:

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
        service.AutodiscoverUrl("someone@somewhere.com");

        ExtendedPropertyDefinition def = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, "AppointmenId", MapiPropertyType.String);

        Guid testid = Guid.NewGuid ();

        Appointment appointment = new Appointment(service);
        appointment.Subject = "Test";
        appointment.Start = DateTime.Now.AddHours(1);
        appointment.End = DateTime.Now.AddHours(2);
        appointment.SetExtendedProperty(def, testid.ToString());
        appointment.Save(WellKnownFolderName.Calendar);

        SearchFilter filter = new SearchFilter.IsEqualTo(def, testid.ToString());

        FindItemsResults<Item> fir = service.FindItems(WellKnownFolderName.Calendar, filter, new ItemView(10));

希望这对您有帮助...

hope this helps you...

这篇关于Exchange Webservice托管API-通过扩展属性查找项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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