Fetch Messages from Exchange Server Mailbox using WebDav
Contents
[
Hide
]
Listing Messages on an Exchange Server used the listMessages() method to get a list of messages from an Exchange Server mailbox. The listMessages() method gets basic information about messages, for example, the subject, the message ID, from and to.
To get the complete message details, Aspose.Email.Exchange provides the ExchangeClient.fetchMessage() method. This method accepts the message URI as a parameter and returns an instance of the MailMessage class. The MailMessage class then provides message details like the body, headers, and attachments.
Fetch Messages from an Exchange Server Mailbox
To fetch messages from Exchange Server Mailbox:
- Create an instance of type ExchangeClient.
- Specify the server name, user name, password, and domain.
- Call the listMessages method to get the ExchangeMessageInfoCollection.
- Loop through the ExchangeMessageInfoCollection collection to get ExchangeMessageInfo.getUniqueUri values.
- Call ExchangeClient.fetchMessage() and pass ExchangeMessageInfo.getUniqueUri as parameter.
The following code snippet connects to the Exchange Server mailbox and fetches all the messages.