I’ve been having some problems over the past 2 weeks with accessing new emails hosted on the Office Exchange 365 servers using EWS.
Mail folders that have only old emails (3 weeks old) seem to work correctly, however any folders that have newly received emails fail on message retrieval.
Here is the code - note that m_username, m_password, m_domain and m_serviceUrl are all populated with correct values - I can call in and retrieve almost all information.
Code:
Dim credentials = If(String.IsNullOrEmpty(m_username), New NetworkCredential, New NetworkCredential(m_username, m_password, m_domain))
m_mapiSession = EWSClient.GetEWSClient(m_serviceUrl, credentials)
Dim mailboxInfo = m_mapiSession.GetMailboxInfo()
Dim test2 = m_mapiSession.ListMessages(mailboxInfo.InboxUri) // This line throws an exception
The exception is as follows:
System.NullReferenceException was unhandled by user code
Message=Object reference not set to an instance of an object.
Source=Aspose.Email
StackTrace:
at . (EmailAddressType[] , String )
at . (ItemType )
at . (ICollection`1 , String , Boolean , Int32 , ExchangeListMessagesOptions )
at .ListMessages(String , ExchangeListMessagesOptions )
This is using Aspose.Email 5.6.0.0 and we are connecting to the Microsoft Hosted Exchange servers.
Domain: [outlook.office365.com](http://outlook.office365.com/)
Server: [https://outlook.office365.com/EWS/Exchange.asmx ](https://outlook.office365.com/EWS/Exchange.asmx)