Hi,
According to your online sample code, I need to provide the exchange mailbox URI for the relevant account in the following way:
ExchangeClient client = new ExchangeClient(“http://servername/exchange/username”,
“username”, “password”, “domain”);
However, if I replace this example with my actual exchange server name and my mailbox info, I get an exception of ‘The remote server returned an error: 501 Not Implemented.’
According to our IT Support team, the URI above is not supported by Exchange 2013.
Is this the only way I’m able to provide the exchange server information?
Thanks
Hi Daniel,
Thank you for using Aspose.Email.
You need to use the Exchange Web Service (EWS) code sample rather than Exchange Client which is for Exchange Server 2003 and 2010 only. From Exchange Server 2010 and onwards, EWS is used.
Sample Code:
// Create instance of IEWSClient class by giving credentials
IEWSClient client = EWSClient.GetEWSClient(“https:[//outlook.office365.com/ews/exchange.asmx](https://outlook.office365.com/ews/exchange.asmx)”, “testUser”, “pwd”, “domain”);
// Call ListMessages method to list messages info from Inbox
ExchangeMessageInfoCollection msgCollection = client.ListMessages(client.MailboxInfo.InboxUri);
// Loop through the collection to get Message URI
foreach (ExchangeMessageInfo msgInfo in msgCollection)
{
string strMessageURI = msgInfo.UniqueUri;
// Now save the message in disk
client.SaveMessage(strMessageURI, @“e:” + msgInfo.MessageId + “.eml”);
}