Email 处理控件Aspose.Email 教程(4):从 Microsoft Exchange Server 获取联系人列表

(一) C# .NET API 从 MS Exchange Server 获取联系人列表

要从 Microsoft Exchange Server 检索联系人,我们将使用Aspose.Email for Java。它是一个强大的 API,提供了一系列功能来实现电子邮件客户端应用程序。此外,它还允许您无缝连接到 MS Exchange Server 并与之一起工作。您可以下载API 的 DLL 或使用以下命令从NuGet安装它。

PM> Install-Package Aspose.Email

(二) 在 C# 中从 MS Exchange Server 检索联系人列表

以下是使用 C# 从 Microsoft Exchange Server 获取联系人列表的步骤。

  • 首先,使用用户名、密码、域和邮箱 URI初始化IEWSClient对象。
  • 然后,调用IEWSClient.GetContacts(EWSClient.MailboxInfo.ContactsUri)方法获取数组中的联系人。
  • 最后,查阅数组中的每个联系人并获取其详细信息。

以下代码示例显示了如何使用 C# 从 Microsoft Exchange Server 获取联系人列表。

// Create instance of IEWSClient class by giving credentialsIEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");// List all the contactsContact[] contacts = client.GetContacts(client.MailboxInfo.ContactsUri);foreach (MapiContact contact in contacts){// Display name and email addressConsole.WriteLine("Name: " + contact.NameInfo.DisplayName + ", Email Address: " + contact.ElectronicAddresses.Email1);}
(三) 通过 ID 从 MS Exchange Server 获取联系人

Aspose.Email for .NET 还允许您使用其 ID 检索联系人。为此,您必须提前知道联系人 ID。以下是在 C# 中从 MS Exchange Server 检索联系人的步骤。

  • 首先,使用用户名、密码、域和邮箱 URI初始化IEWSClient对象。
  • 然后,调用IEWSClient.GetContact()方法并在Contact对象中获取联系人。
  • 最后,根据需要使用或操作联系人。

以下代码示例展示了如何使用 C# 从 Microsoft Exchange Server 检索特定联系人。

// Create instance of IEWSClient class by giving credentialsIEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");string id = "<<Contact ID>>";// Get contactContact fetchedContact = client.GetContact(id);// Use or manipulate contact
(四) 结论

欢迎下载|体验更多Aspose产品 

获取更多信息请咨询在线客服 或 加入Aspose技术交流群(

Email 处理控件Aspose.Email 教程(4):从 Microsoft Exchange Server 获取联系人列表
标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2022年1月27日
下一篇 2022年1月27日

相关推荐

发表回复

登录后才能评论