6

EWS で予定に拡張プロパティを使用しようとしましたが、予定が再び見つからないようです。プロパティの設定部分は、この質問に示されているものと同じです。

ASP.NET で Exchange Web サービス マネージ 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);

どんな助けでも大歓迎です。

編集: ドキュメントが示すようにプロパティを作成しようとすると:

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

Guid im がプロパティ値として追加されているため、失敗します。:-/

もう一度編集: 今日のすべての予定を取得し、作成したばかりの予定からプロパティを取得しようとしましたが、{} なしで保存したものと同じであるため、フィルターを使用する必要があります。

もう一度編集 *

 ExtendedPropertyDefinition extendedProperty = new ExtendedPropertyDefinition(

私が使用する場合:

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

プロパティを持つすべての予定を検索しますが、特定の予定を検索すると:

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

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

その後、何も見つかりません。

4

3 に答える 3

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

これがお役に立てば幸いです...

于 2013-02-28T12:50:36.587 に答える
0

予定の受信トレイを検索します。そこでは、それらを見つけることはできません。代わりにカレンダーで検索してみてください。

于 2013-02-27T11:42:56.983 に答える
0

これは、GUID を拡張プロパティとして配置し、GUID に基づいて予定を取得する例です。

private static readonly PropertyDefinitionBase AppointementIdPropertyDefinition = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, "AppointmentID", MapiPropertyType.String);
public static PropertySet PropertySet = new PropertySet(BasePropertySet.FirstClassProperties, AppointementIdPropertyDefinition);


//Setting the property for the appointment 
 public static void SetGuidForAppointement(Appointment appointment)
{
    try
    {
        appointment.SetExtendedProperty((ExtendedPropertyDefinition)AppointementIdPropertyDefinition, Guid.NewGuid().ToString());
        appointment.Update(ConflictResolutionMode.AlwaysOverwrite, SendInvitationsOrCancellationsMode.SendToNone);
    }
    catch (Exception ex)
    {
        // logging the exception
    }
}

//Getting the property for the appointment
 public static string GetGuidForAppointement(Appointment appointment)
{
    var result = "";
    try
    {
        appointment.Load(PropertySet);
        foreach (var extendedProperty in appointment.ExtendedProperties)
        {
            if (extendedProperty.PropertyDefinition.Name == "AppointmentID")
            {
                result = extendedProperty.Value.ToString();
            }
        }
    }
    catch (Exception ex)
    {
     // logging the exception
    }
    return result;
} 
于 2013-02-27T15:00:47.877 に答える