Exchange Webservice Managed API - 按扩展属性查找项目

Jac*_*cob 6 c# exchange-server exchangewebservices

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

如何从ASP.NET中的Exchange Web Service托管API 2.0更新约会

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

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

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

这是查找的代码:

        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);
Run Code Online (Sandbox Code Playgroud)

任何帮助是极大的赞赏.

编辑: 当我尝试创建属性时,如文档所示:

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

它失败了,因为它是一个Guid我添加为属性值.: - /

再次编辑: 刚刚尝试获取今天的所有约会,并从我刚刚创建的约会获取属性,并且它与我存储的相同,没有{},因此它必须与过滤器一起使用.

再次编辑* 它有一些关系

 ExtendedPropertyDefinition extendedProperty = new ExtendedPropertyDefinition(
Run Code Online (Sandbox Code Playgroud)

如果我使用:

 new ExtendedPropertyDefinition(
                DefaultExtendedPropertySet.Appointment,
                "AppointmentID",
                MapiPropertyType.String);
Run Code Online (Sandbox Code Playgroud)

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

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

 ExtendedPropertyDefinition extendedProperty =
            new ExtendedPropertyDefinition(
                MyPropertySetId,
                "AppointmentID",
                MapiPropertyType.String);
Run Code Online (Sandbox Code Playgroud)

然后找不到任何东西.

Jür*_*ann 22

这是一个示例代码,如何使用customid创建约会并在保存后找到它:

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));
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助你......