Connecting to Exchange Server
Connect to Exchange Server using Exchange Web Service (EWS)
In order to connect to Exchange servers 2007, 2010 and 2013 using Exchange Web Service, it provides the IEWSClient
interface that implements the EWSClient
class. The EWSClient.getEWSClient
method instantiates and returns an IEWSClient
object that is further used to perform operations related to an Exchange mailbox and other folders. This article shows how to instantiate objects of both classes and the same method can be used in all the upcoming examples in this programming guide.
The following code sample shows how to connect to Exchange Server using EWS.
Connect to an Exchange Server using IMAP
Microsoft Exchange Server supports the IMAP protocol for accessing items in a mailbox. Use Aspose.Email’s ImapClient
class to connect to the Exchange Server using the IMAP protocol. This article shows how.
For more information about the ImapClient
class, read Managing Emails with IMAP.
First, make sure that IMAP services are enabled for your Exchange Server:
- Open the Control Panel.
- Go to Administrator Tools, then Services.
- Check the status of the Microsoft Exchange IMAP4 service.
- If it is not already running, enable/start it.
Below is the sample source code to connect and list messages from the Inbox folder of Microsoft Exchange Server using the IMAP protocol.
Programming Sample - Saving One Message Only
After connecting to an Exchange server using IMAP and getting the IMapMessageInfoCollection, you can use the MessageInfo object’s sequence number to save a specific message as follow: