0
votes

I am trying to use EWS to access a process mailbox. For some automated queries we created a genric process mailbox. I want to parse emails by watching the Process inbox.

My code was working earlier with the old exchange server. But after migration to office 365 it fails.

I am able to access my mailbox and parse on the office 365 using my credentials.

How do I access this process mailbox? Earlier I create an ExchangeService and connect to the process email address with UseDefaultCredentials = true.

I set the AutoDiscoverURl and used DefaultCredentials. But When I tried to read emails I get "The SMTP address has no mailbox associated with it."

EDIT: I tried to use my own credentials instead of the Default Credentials.

string smtpaddress = "[email protected]";
es.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
es.Credentials = new WebCredentials("myemail", "mypassword");
es.AutodiscoverUrl(smtpaddress, RedirectionCallback);
FolderId SharedMailbox = new FolderId(WellKnownFolderName.Inbox, "[email protected]");
Folder sharedInbox = Folder.Bind(es, SharedMailbox);

At this point I can check sharedInbox containing the details of the Inbox. I can see the unread email count and others.

But when I access

ItemView itemView = new ItemView(100);
FindItemsResults<Item> findResults1 = es.FindItems(pqInbox.Id, itemView);

I get exception "SMTP address has no mailbox associated with it"

1

1 Answers

0
votes

disclaimer: I haven't worked with EWS in a while.

You can't use the default credentials for Office 365. You'll need to provide either the basic credential or use an OAuth token.

You should confirm that the account was migrated to Office 365. Login to OWA and look at the URL to make sure you are using Office 365 and not an on-premise server.

This was already answered by Exchange Web Services: UseDefaultCredentials property