asp.netc#-3.0office365office365apio365rwsclient

How to read another user outlook 365 mail in c#


I have integrated an asp.net web application with office 365 mail using o365 api client library.I have a specific requirement, suppose I have stored the o365 mail id of other users in my database.The o365 mail username/ password also stored in my local database. Is there any way to see the other user's mail details using the mail id/ credentials? If anybody has any idea please share.

Thanks in advance.


Solution

  • If your app is using OAuth code flow , it seems that only allow access to mail, calendar and contacts belonging to the authenticated user . You may use OAuth2 client credential flow, for your scenario and the app will be able to make calls to interact with any mailboxes in that tenant. Another choice is to use EWS Managed API ,since you get the password of the other user ,you will get the credentials like:

      ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
      service.Credentials = new WebCredentials("user_with_access@example.com", "password");
    

    Check this thread for a demo.