0
votes

I have read emails from Exchange online in c#.net using Office 365 API, but getting some issue on response object

(HttpResponseMessage response = await client.SendAsync(request))

i.e

{StatusCode: 403, ReasonPhrase: 'Forbidden', Version: 1.1, Content:     

System.Net.Http.StreamContent, Headers:
{
  Transfer-Encoding: chunked
  request-id: a0983ea5-313d-4234-b1c6-249f3359c71c
  client-request-id: a0983ea5-313d-4234-b1c6-249f3359c71c
  x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"SouthEast    
  Asia","Slice":"SliceB","ScaleUnit":"002","Host":"AGSFE_IN_3","ADSiteName":"SIN"}     
}

  OutBoundDuration: 906.2963
  Duration: 1177.9769
  Cache-Control: private
  Date: Wed, 23 Dec 2015 12:08:42 GMT
  Server: Microsoft-IIS/8.5
  X-Powered-By: ASP.NET
  Content-Type: application/json
}}

For more information :

  1. Please refer this link : http://dev.office.com/getting- started/office365apis

  2. Provide required information login,app name etc.

  3. Download app and run your system

  4. In run time ,error occurred on response object

So Please tell me how to fixed it and let me know if any information required. Please help me out.

Thanks, Sheena

2

2 Answers

0
votes

You have to register your application on Azure Active Directory (AAD) and set the application permissions to read emails in your app registration.

Check out this presentations starting fromr slide #24: http://www.mostafaelzoghbi.com/2015/10/identity-and-office-365-presentation-on.html

Hope this helps.

0
votes

Exchange mailbox access by API was disabled for that account. Please follow https://msdn.microsoft.com/en-us/library/office/dn467892(v=exchg.150).aspx to enable it, e.g. Set-CASMailbox –Identity [email protected] -EwsEnabled:$true