none
Outlook REST API from Windows XP RRS feed

  • Question

  • I wrote a custom C# console application several years ago that utilized our Lotus Notes client to send email notifications and search new emails for codes in subject lines to instruct my application to override certain functions. It's currently scheduled to run every 15 minutes on a virtual XP machine. 

    Recently, my company switched from Lotus Notes to Office 365. I'd like to be able to change my C# console code to use the Outlook REST API to access my mail, but frankly my head is spinning trying to wrap my brain around all the AD, Azure, authentication, tokens, tenants, gobbledegook.

    Essentially, all my application has to be able to do is compose and send email, and search the subject lines of all of my personal emails received since a particular date/time for a particular key word. I don't need to be able to read the email body -- just the subject.

    I have logged into the Microsoft Application Registration Portal and created an Application ID. And that's it. I'm not sure where to even start.

    Can someone either step me through the process? Or point me to a good tutorial to get me started?

    Thanks!!


    Tuesday, June 7, 2016 7:30 PM

Answers

  • Deleted
    Wednesday, June 8, 2016 6:30 AM
  • Since your app was registered in the Application Registration Portal. You could refer to below article for  process of calling the Outlook Mail API to retrieve messages in Office 365 :

    https://dev.outlook.com/restapi/getstarted

    In order to call the Mail API, the app requires an access token from Azure Active Directory. In order to do that, the app implements the Authorization Grant Flow .Above guide focuses on the OAuth and REST requests and responses , and covers the sequence of requests and responses that an app uses to authenticate and retrieve messages.

    Your requirement is to access O365 Mail Rest API in console application .  In Application Registration Portal you could register a mobile application(native application) .With application id you could get an authorization code in Authorization Grant Flow , after that you could get an access token with the code .Please refer to below demo which introduces the auth basic concept:

    https://github.com/dream-365/OfficeDev-Samples/tree/master/samples/Office365DevQuickStart/OAuth2-basic

    With above demo , you need to use Version.V2(oauth2/v2.0) and call the AcquireTokenWithScope function :

    var tokenResponse = auth.AcquireTokenWithScope("https://outlook.office.com/mail.read");

    And make sure you get the same redirect url with app redirect url in the portal .

    If you are using Azure AD to register the application , below demo is for your reference :

    http://simonjaeger.com/understand-the-microsoft-graph-with-a-console-app/

    Best Regards,

    Nan Yu

    Wednesday, June 8, 2016 7:49 AM
    Moderator

All replies

  • Deleted
    Wednesday, June 8, 2016 6:30 AM
  • Since your app was registered in the Application Registration Portal. You could refer to below article for  process of calling the Outlook Mail API to retrieve messages in Office 365 :

    https://dev.outlook.com/restapi/getstarted

    In order to call the Mail API, the app requires an access token from Azure Active Directory. In order to do that, the app implements the Authorization Grant Flow .Above guide focuses on the OAuth and REST requests and responses , and covers the sequence of requests and responses that an app uses to authenticate and retrieve messages.

    Your requirement is to access O365 Mail Rest API in console application .  In Application Registration Portal you could register a mobile application(native application) .With application id you could get an authorization code in Authorization Grant Flow , after that you could get an access token with the code .Please refer to below demo which introduces the auth basic concept:

    https://github.com/dream-365/OfficeDev-Samples/tree/master/samples/Office365DevQuickStart/OAuth2-basic

    With above demo , you need to use Version.V2(oauth2/v2.0) and call the AcquireTokenWithScope function :

    var tokenResponse = auth.AcquireTokenWithScope("https://outlook.office.com/mail.read");

    And make sure you get the same redirect url with app redirect url in the portal .

    If you are using Azure AD to register the application , below demo is for your reference :

    http://simonjaeger.com/understand-the-microsoft-graph-with-a-console-app/

    Best Regards,

    Nan Yu

    Wednesday, June 8, 2016 7:49 AM
    Moderator