{"id":22511917,"url":"https://github.com/jandev/mailboxreader","last_synced_at":"2025-03-28T00:46:37.123Z","repository":{"id":72844963,"uuid":"274871054","full_name":"Jandev/MailboxReader","owner":"Jandev","description":"Sample project which is able to read the mailbox of a user using Azure Active Directory and Office 365 using Microsoft Graph API","archived":false,"fork":false,"pushed_at":"2024-06-12T06:53:38.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-02T02:43:22.232Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Jandev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-25T08:57:52.000Z","updated_at":"2024-06-12T06:53:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"ccf73041-b64b-4f63-be0c-d5ce6fba7f79","html_url":"https://github.com/Jandev/MailboxReader","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jandev%2FMailboxReader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jandev%2FMailboxReader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jandev%2FMailboxReader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jandev%2FMailboxReader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jandev","download_url":"https://codeload.github.com/Jandev/MailboxReader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245949603,"owners_count":20698921,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-07T02:14:32.163Z","updated_at":"2025-03-28T00:46:37.102Z","avatar_url":"https://github.com/Jandev.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MailboxReader\nSample project which is able to read the mailbox of a user using Azure Active Directory and Office 365 using Microsoft Graph API\n\nWith 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 \u0026 in Office 365.\n\n## Run the project\n\nIn order to run the project you need the following settings\n```json\n{\n  \"AppRegistration:ApplicationId\": \"\u003cThe Application Id of the App Registration in Azure Active Directory\u003e\",\n  \"AppRegistration:ApplicationSecret\": \"\u003cThe Secret created in the App Registration\u003e\",\n  \"AppRegistration:TenantId\": \"\u003cThe unique identifier of the tenant\u003e\",\n  \"AppRegistration:RedirectUri\": \"\u003cThe redirect uri configured in the App Registration\u003e\",\n  \"AppRegistration:Domain\": \"\u003cThe domainname of your tenant most of the time something like [name].onmicrosoft.com\u003e\",\n  \"Query:UserEmailAddress\": \"\u003cthe configured mailbox, like person@mail.com\u003e\",\n  \"Query:UserIdentifier\": \"\u003cunique identifier of the user you want to read the mail from\u003e\",\n  \"Query:FindUser\": \"\u003cwhen using the e-mail address and find user, set to `true`, if finding mailbox using identifier set to `false`\"\n}\n```\n\n## Configuring Azure Active Directory\n\n1. Create a new App Registration in Azure Active Directory\n2. For the `Redirect URI` use something like `https://localhost:8080/`\n3. 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\n4. Add the following `API permissions`\n    * `Mail.Read`\n    * `User.Read`\n    * `User.Read.All`\n\nHaving configured this, your application is now able to query all mailboxes within your tenant, so hurry up to the next chapter.\n\n## Configuring Office 365 / Exchange\n\nThese steps are taken from the [Microsoft Graph documentation](https://docs.microsoft.com/en-us/graph/auth-limit-mailbox-access#configure-applicationaccesspolicy).\n\n1. Connect to Exchange Online PowerShell\n2. Create an application access policy.\n```powershell\nNew-ApplicationAccessPolicy -AppId \u003cApplicationId of the App Registration\u003e -PolicyScopeGroupId \u003cGroupId where policy applies to\u003e -AccessRight RestrictAccess -Description \"\u003cA nice description\u003e\"\n```\n3. Test the access policy\n```powershell\nTest-ApplicationAccessPolicy -Identity \u003cuser in the specified GroupId\u003e -AppId \u003cApplicationId of the App Registration\u003e\n```\nDo note, the synchronisation of the access restriction can take a long time. The docs state 30 minutes, but I noticed it can take longer.\n\n# Credits\nGot a lot of inspiration \u0026 implementation from [the Microsoft Graph .NET Core samples](https://github.com/microsoftgraph/dotnetcore-console-sample)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjandev%2Fmailboxreader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjandev%2Fmailboxreader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjandev%2Fmailboxreader/lists"}