1

2つの質問があります

  1. メールの連絡先をExchangeサーバーに追加したい。EWSを使用したサンプルコードを見たが、そのコードはユーザー固有の連絡先を追加するために使用された。連絡先ドメイン固有の追加方法。

  2. Exchangeサーバーからドメインの連絡先を取得したい。今日追加または変更された連絡先のみが必要なすべての連絡先は必要ありません。

どうすればこれを達成できますか?誰かが私を助けてくれますか?

よろしくVairamuthu.GS

4

1 に答える 1

1

「連絡先ドメイン固有」がわかりませんでしたが、コードを共有します。役立つかもしれません

連絡先の追加

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
// you should set the credentials of the user and 
//call AutoDiscover to get the service URL before executing the code
Contact newcontact = new Contact(service);
newcontact.DisplayName = "data";
newcontact.EmailAddresses[EmailAddressKey.EmailAddress1] = new EmailAddress();
newcontact.EmailAddresses[EmailAddressKey.EmailAddress1].Address = "data";
newcontact.EmailAddresses[EmailAddressKey.EmailAddress1].Name = newcontact.DisplayName;
newcontact.FileAs = newcontact.DisplayName;
newcontact.Save();

新しい連絡先は、ログインしているユーザーのメールボックスの連絡先フォルダーに保存されます。

取得した連絡先のフィルタリング

SearchFilter filter = new SearchFilter.IsGreaterThan(ItemSchema.DateTimeCreated, DateTime.Now.AddDays(-1));
FindItemsResults<Item> contactCreatedToday = service.FindItems(WellKnownFolderName.Contacts, filter, new ItemView(int.MaxValue));
foreach (Item t in contactCreatedToday)
{
    try
    {
        Contact c = (Contact) t;
        //do processing
    }
    catch (InvalidCastException)
    {
        throw;
    }
}
于 2012-07-30T16:48:43.450 に答える