Code Monkey home page Code Monkey logo

mailboxreader's Introduction

MailboxReader

Sample project which is able to read the mailbox of a user using Azure Active Directory and Office 365 using Microsoft Graph API

With this tool you're able to list the e-mails of a configured mailbox. Of course, it's necessary to have the appropriate permissions from Azure Active Directory & in Office 365.

Run the project

In order to run the project you need the following settings

{
  "AppRegistration:ApplicationId": "<The Application Id of the App Registration in Azure Active Directory>",
  "AppRegistration:ApplicationSecret": "<The Secret created in the App Registration>",
  "AppRegistration:TenantId": "<The unique identifier of the tenant>",
  "AppRegistration:RedirectUri": "<The redirect uri configured in the App Registration>",
  "AppRegistration:Domain": "<The domainname of your tenant most of the time something like [name].onmicrosoft.com>",
  "Query:UserEmailAddress": "<the configured mailbox, like [email protected]>",
  "Query:UserIdentifier": "<unique identifier of the user you want to read the mail from>",
  "Query:FindUser": "<when using the e-mail address and find user, set to `true`, if finding mailbox using identifier set to `false`"
}

Configuring Azure Active Directory

  1. Create a new App Registration in Azure Active Directory
  2. For the Redirect URI use something like https://localhost:8080/
  3. Add a new secret in the App Registration and make sure to copy the value, so you can put it in the configuration later on
  4. Add the following API permissions
    • Mail.Read
    • User.Read
    • User.Read.All

Having configured this, your application is now able to query all mailboxes within your tenant, so hurry up to the next chapter.

Configuring Office 365 / Exchange

These steps are taken from the Microsoft Graph documentation.

  1. Connect to Exchange Online PowerShell
  2. Create an application access policy.
New-ApplicationAccessPolicy -AppId <ApplicationId of the App Registration> -PolicyScopeGroupId <GroupId where policy applies to> -AccessRight RestrictAccess -Description "<A nice description>"
  1. Test the access policy
Test-ApplicationAccessPolicy -Identity <user in the specified GroupId> -AppId <ApplicationId of the App Registration>

Do note, the synchronisation of the access restriction can take a long time. The docs state 30 minutes, but I noticed it can take longer.

Credits

Got a lot of inspiration & implementation from the Microsoft Graph .NET Core samples

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.