Free Support Forum - aspose.com

Aspose.Email: Fetching all email addresses in an address list from Exchange

Hi,

We’re considering to purchase Aspose.Email for Java to develop an app that will scan Exchange Server.
We intend to use EWS where possible and were looking for a functionality to fetch the email address in some address list that’s defined in Exchange Server (possibly the GAL).
This seems to be possible using EWS’ “FindPeople” operation.

Is this possible with Aspose.Email for Java?
If not, is it going to be added or can we request to add it (if we purchase)?

Thanks,
Itai

@marki

Please find below some of the key features provided by Aspose.Email for working with Exchange Server:

  • Connect to Microsoft Exchange Server 2003, 2007, 2010 and 2013.
  • Retrieve emails from Exchange Server.
  • List mail messages.
  • Retrieve mailbox information.
  • Email management features.
  • Delete selected emails on Exchange Server.

For specifically working with EWS, Aspose.Email provides very handful functionality. Please follow the link below for more details about working with EWS Exchange Server:
https://docs.aspose.com/display/emailjava/Working+with+Exchange+EWS+Client

For fetching email addresses, Aspose.Email allows you to retrieve contact information from an Exchange Server directly or using EWS. Please follow the link below explaining how you can

Moreover, you may use the following sample code for accessing the global address list returning MapiContact collection.

IEWSClient clientCallback = EWSClient.GetEWSClient("https://exchange.domain.com/ews/Exchange.asmx", "username", "password", "domain.com");
var Mailboxes = clientCallback.ListMailboxes();

Thank you for the quick reply!

The sample code you gave looks promising for fetching the entire GAL. I overlooked the listMailboxes() method when searching through Aspose.Email docs.
However, I was looking for a way to fetch only a subset of the GAL, just the contacts of an address list (preferably only a list of SMTP email addresses to keep this operation with low latency and throughput).

I saw that this can be done with the FindPeople operation that was added to EWS in Exchange 2013.
For example, Microsoft’s C# sdk for EWS supports the FindPeople operation (see the FindPeople() overloads in the ExchangeService class).
However, Microsoft’s Java sdk for EWS lacks this functionality and I was hoping to find it in Aspose.Email.

Is there support for such functionality in Aspose.Email for Java?
If not, is it going to be added to the library?

Thanks,
Itai

@marki

Aspose.Email for working with Exchange Server using EWS provides functionality to get all contacts from a specified client’s mailbox info. Please have a look on the following code sample:

IEWSClient client = EWSClient.getEWSClient("https://exchange.domain.com/ews/Exchange.asmx", "username", "password", "domain.com");
// List all the contacts
Contact[] contacts = client.getContacts(client.getMailboxInfo().getContactsUri());
// Loop through all contacts
for (Contact contact : contacts) {
	// Display name and email address
	System.out.println("Name: " + contact.getDisplayName() + ", Email Address: " + contact.getEmailAddresses().get_Item(0));
}

Moreover, we have logged your specific requirements for further investigation and possible enhancement under issue ID “EMAILJAVA-34425”. You will automatically be notified here once we have more information to share with you.

The issues you have found earlier (filed as EMAILJAVA-34425) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan

@marki

This issue has been resolved and new API features are introduced in our latest version of Aspose.Email for Java 18.10.

You may find contacts located in the global address list (GAL) using the following code sample:

IEWSClient client = createEWSClient();

Contact[] findPeople = client.findPeople("smtp", 10);

For find contacts located in the specified user’s personal mailbox, you may use the following code sample:

IEWSClient client = createEWSClient();

ContactQueryBuilder queryBuilder = new ContactQueryBuilder();
queryBuilder.getContactDisplayName().contains("testContact");
java.util.Calendar c = java.util.Calendar.getInstance();
c.add(java.util.Calendar.DATE, -1);
queryBuilder.getContactCreationTime().greater(c.getTime());

Contact[] findPeople = client.findPeople(client.getMailboxInfo().getContactsUri(), 
    queryBuilder.getQuery(), 10);