We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Null reference exception when using OAuth for Office 365


I’m trying to connect to an Office 365 email account using OAuth. I already have the token, so I create the OAuthNetworkCredential with it. But when I try to create the EWSClient I get a null reference exception. Through fiddler I can see it doesn’t do any request and if I try to create the client using username and password credentials, it works. Here’s the stack trace:

at Aspose.Email.Exchange.Schema.Exchange_2013.ExchangeServiceBinding.GetWebRequest(Uri uri)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at Aspose.Email.Exchange.Schema.Exchange_2013.ExchangeServiceBinding.GetFolder(GetFolderType GetFolder1)
at Aspose.Email.Exchange.EWSClient.GetEWSClient(String mailboxUri, ICredentials credentials, WebProxy proxy)
at Aspose.Email.Exchange.EWSClient.GetEWSClient(String mailboxUri, ICredentials credentials)
at MyProject.Microsoft.Mail.GetItems() in C:\MyProject\Microsoft\Mail.cs:line 27


Thank you for contacting Aspose support team.

We have analyzed the issue and have logged investigation ticket as EMAILNET-38816 for the product team. You will be automatically notified once any update is received in this regard.


We are working on this issue and need little assistance. Could you please provide us refresh token and any test account credentials which can be used for testing? It will help us to observe the problem and provide assistance accordingly.