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

Free Support Forum - aspose.com

How to delete older emails in Office365

Hi,

Could you please provide code on how to delete emails (say 90 days older ) from folder created by me in Office 365 using IEWSClient

Thanks
Gowtham A

@Gowtham5555,

Thank you for contacting Aspose support team.

You may please give a try to the following sample code and share the feedback.

IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");
MailQueryBuilder builder = new MailQueryBuilder();
builder.InternalDate.Before(DateTime.Now);
builder.InternalDate.Since(DateTime.Now.AddDays(-90));
MailQuery query = builder.GetQuery();
// Get list of messages
ExchangeMessageInfoCollection messages = client.ListMessages(client.MailboxInfo.InboxUri, query, false);
client.DeleteMessages(messages);