Aspose.Email for .NET如何获取邮件联系人的扩展信息

作者:控件中国网   出处:控件中国网   2016-10-18 09:09:45   阅读:8

在这个月 Aspose.Email for .NET邮件处理控件发布了新的16.10版本,通过该控件开发人员可以使用API来像OutLook一样在应用程序中对邮件进行发送、接收、读取和处理,在新的版本中开发人员可以通过API获取联系人信息和扩展属性,如何获取联系人的扩展信息可以参考下面的部分代码:
IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");
//The required extended properties must be added in order to create or read them from the Exchange Server
string[] extraFields = new string[] {{ "User Field 1", "User Field 2", "User Field 3", "User Field 4" }};
foreach (string extraField in extraFields)
    client.ContactExtendedPropertiesDefinition.Add(extraField);
 
//Create a test contact on the Exchange Server
Contact contact = new Contact();
contact.DisplayName = "EMAILNET-38433 - " + Guid.NewGuid().ToString();
foreach (string extraField in extraFields)
    contact.ExtendedProperties.Add(extraField, extraField);
 
string contactId = client.CreateContact(contact);
 
//retrieve the contact back from the server after some time
Thread.Sleep(5000);
contact = client.GetContact(contactId);
 
//Parse the extended properties of contact 
foreach (string extraField in extraFields)
    if (contact.ExtendedProperties.ContainsKey(extraField)) 
        Console.WriteLine(contact.ExtendedProperties[extraField].ToString());
Copyright© 2006-2015 ComponentCN.com all rights reserved.重庆磐岩科技有限公司(控件中国网) 版权所有 渝ICP备12000264号 法律顾问:元炳律师事务所
客服软件
live chat