Free Support Forum -

System.NullReferenceException using IEWSClient.Backup

I’m trying to use the Backup() method of the IEWSClient interface, however I keep running into null reference exceptions. The code from my test application is pretty simple:

IEWSClient client = EWSClient.GetEWSClient("", "", "password", "");
ExchangeFolderInfoCollection col = client.ListSubFolders(client.MailboxInfo.RootUri);
client.Backup(client.ListSubFolders(client.MailboxInfo.RootUri), @"d:\dev\test.pst", BackupOptions.Recursive); // System.NullReferenceException: 'Object reference not set to an instance of an object.'

The last line always throws a null reference exception, though I can’t see why. All the objects have values, and a PST file (though 256KB and empty) is created before the exception is thrown.

Am I doing something wrong in the creation of the IEWSClient object?

If it helps, my goal is to create an application that can be given to some of our users so that they can export their mailboxes from Exchange Online to PST files without having to use Outlook. If there is a better way to accomplish this, can someone point me in the right direction?

I appreciate any assistance you can give.


Can you please try using latest Aspose.Email for .NET 20.10 on your end. In case there is still an issue then please share the test account credentials used on your end that we may use to test and verify the issue.

Many thanks for getting back to me. I think it may be to do with the test mailbox itself as I’ve tried on another mailbox and didn’t get that error. I can confirm I’m using the latest version which I added to my test application in Visual Studio via NuGet.

I will try testing with a few other mailboxes just to make sure this was an isolated incident, if I can repeat the problem on an additional mailbox I will share credentials for you to test.


Thank you for sharing the feedback. We are here to help you further if there is any issue.