【问题标题】:How to add the contact using EWS如何使用 EWS 添加联系人
【发布时间】:2012-05-15 08:52:33
【问题描述】:

我有 2 个问题

  1. 我想将电子邮件联系人添加到 Exchange 服务器。我已经看到使用 EWS 的示例代码。但是该代码用于添加特定于用户的联系人。如何添加特定于域的联系人。

  2. 我想从 Exchange 服务器获取域联系人。我不想要我只需要今天添加或修改的联系人的所有联系人。

我怎样才能做到这一点。谁能帮助我?

问候 Vairamuthu.G.S

【问题讨论】:

    标签: exchangewebservices


    【解决方案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;
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2014-10-05
      • 2012-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-26
      • 2012-06-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多