{"id":5802,"date":"2021-02-04T18:06:16","date_gmt":"2021-02-04T16:06:16","guid":{"rendered":"https:\/\/www.limilabs.com\/blog\/?p=5802"},"modified":"2023-01-20T12:07:57","modified_gmt":"2023-01-20T10:07:57","slug":"shared-mailbox-office365","status":"publish","type":"post","link":"https:\/\/www.limilabs.com\/blog\/shared-mailbox-office365","title":{"rendered":"Access shared\/delegate mailbox of Office 365"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Enable IMAP\/POP3<\/h2>\n\n\n\n<p>First make sure IMAP \/ POP3 are turned on properly: <a href=\"\/blog\/office365-enable-imap-pop3-smtp\" title=\"Enable IMAP \/ POP3 in Office 365\">Enable IMAP \/ POP3 in Office 365<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Shared mailbox permissions<\/h2>\n\n\n\n<p>Make sure you have access to the shared mailbox. Log in to <strong>Microsoft 365 admin portal<\/strong> at <a href=\"https:\/\/admin.microsoft.com\/\">https:\/\/admin.microsoft.com\/<\/a> as an administrator, go to <strong>Users\/Active users<\/strong> tab and select shared mailbox:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2022\/03\/image-10.png\"><img loading=\"lazy\" decoding=\"async\" width=\"570\" height=\"453\" src=\"https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2022\/03\/image-10.png\" alt=\"\" class=\"wp-image-5964\" srcset=\"https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2022\/03\/image-10.png 570w, https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2022\/03\/image-10-300x238.png 300w\" sizes=\"(max-width: 570px) 100vw, 570px\" \/><\/a><\/figure>\n\n\n\n<p>On the <strong>Mail <\/strong>tab, in <strong>Mailbox permissions <\/strong>click <strong>Read and manage permissions<\/strong>:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2022\/03\/image-11.png\"><img loading=\"lazy\" decoding=\"async\" width=\"572\" height=\"550\" src=\"https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2022\/03\/image-11.png\" alt=\"\" class=\"wp-image-5965\" srcset=\"https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2022\/03\/image-11.png 572w, https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2022\/03\/image-11-300x288.png 300w\" sizes=\"(max-width: 572px) 100vw, 572px\" \/><\/a><\/figure>\n\n\n\n<p>Make sure your user is on the list:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2022\/03\/image-12.png\"><img loading=\"lazy\" decoding=\"async\" width=\"564\" height=\"400\" src=\"https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2022\/03\/image-12.png\" alt=\"\" class=\"wp-image-5966\" srcset=\"https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2022\/03\/image-12.png 564w, https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2022\/03\/image-12-300x213.png 300w\" sizes=\"(max-width: 564px) 100vw, 564px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Enable IMAP\/POP3 for shared mailbox<\/h2>\n\n\n\n<p>On the same screen go to <strong>Manage email apps<\/strong>:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2022\/03\/image-13.png\"><img loading=\"lazy\" decoding=\"async\" width=\"527\" height=\"559\" src=\"https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2022\/03\/image-13.png\" alt=\"\" class=\"wp-image-5972\" srcset=\"https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2022\/03\/image-13.png 527w, https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2022\/03\/image-13-283x300.png 283w\" sizes=\"(max-width: 527px) 100vw, 527px\" \/><\/a><\/figure>\n\n\n\n<p>and select <strong>IMAP <\/strong>and <strong>POP3<\/strong>:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2022\/03\/image-14.png\"><img loading=\"lazy\" decoding=\"async\" width=\"465\" height=\"393\" src=\"https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2022\/03\/image-14.png\" alt=\"\" class=\"wp-image-5973\" srcset=\"https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2022\/03\/image-14.png 465w, https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2022\/03\/image-14-300x254.png 300w\" sizes=\"(max-width: 465px) 100vw, 465px\" \/><\/a><\/figure>\n\n\n\n<p>Now, there are 2 ways of accessing a shared mailbox in Office 365: <\/p>\n\n\n\n<p>Using regular IMAP basic authentication and a using OAuth 2.0.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Shared mailbox &#8211; basic authentication [deprecated]<\/h2>\n\n\n\n<p><strong>It is no longer possible to re-enable Basic Auth or use App passwords<\/strong>. <\/p>\n\n\n\n<p>You&#8217;ll need to use OAuth described below.<\/p>\n\n\n\n<p>To use basic authentication you&#8217;ll need to \u00a0re-enable Basic Auth<strong> <\/strong>for your tenant:<br><a href=\"https:\/\/www.limilabs.com\/blog\/office-365-prevent-basic-auth-disabled\">https:\/\/www.limilabs.com\/blog\/office-365-prevent-basic-auth-disabled<\/a><\/p>\n\n\n\n<p>Make sure IMAP\/POP3 access is configured and basic authentication is turned on:<br><a href=\"\/blog\/office365-enable-imap-pop3-smtp\" title=\"Enable IMAP \/ POP3 in Office 365\">Enable IMAP \/ POP3 in Office 365<\/a><\/p>\n\n\n\n<p>Consider using Application passwords for your account instead of your primary password:<br><a href=\"\/blog\/office365-app-passwords\" title=\"Application passwords in Office 365\">Application passwords in Office 365<\/a><\/p>\n\n\n\n<p>Try authenticating to users&#8217; regular mailbox with his credentials (or App password) to check if basic authentication works and the user\/password is correct:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nclient.UseBestLogin(&quot;AlexW@example.com&quot;, &quot;AlexWPass-or-AlexWAppPass&quot;);\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\"> Access the shared mailbox <\/h3>\n\n\n\n<p>Use the following user format:<\/p>\n\n\n\n<p><strong>Username@DomainName\\Shared@DomainName<\/strong><\/p>\n\n\n\n<p>You must use <strong>Login <\/strong>method:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nclient.Login(@&quot;AlexW@example.com\\invoices@example.com&quot;, &quot;AlexWPass-or-AlexWAppPass&quot;); \n<\/pre><\/div>\n\n\n<p>-or- <\/p>\n\n\n\n<p>alternatively you may use <strong>LoginPlain <\/strong>method:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nclient.LoginPlain(&quot;invoices@example.com&quot;, &quot;AlexW@example.com&quot;, &quot;AlexWPass-or-AlexWAppPass&quot;);\n<\/pre><\/div>\n\n\n<p>Don\u2019t use\u00a0<em>UseBestLogin<\/em>\u00a0for Office365 shared mailboxes and basic authentication.<\/p>\n\n\n\n<p> The reason is  Office&nbsp; 365 advertises LOGIN PLAIN as a preferred login method and <em>UseBestLogin<\/em> chooses to use it. However Office 365 does not recognize Username@DomainName\\Shared@DomainName user pattern when using LOGIN PLAIN.  For Office 365 to accept a LOGIN PLAIN to a shared mailbox, you need to provide all 3 parameters separately: shared mailbox, user and user password &#8211; use <em>LoginPlain <\/em>to do that.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"> Shared mailbox &#8211; OAuth 2.0 <\/h2>\n\n\n\n<p>It is much simpler with OAuth. Use any of the available OAuth 2.0 flows:<\/p>\n\n\n\n<p><strong>Daemons\/Services:&nbsp;Password grant&nbsp;<\/strong>(MFA\/2FA must be turned off for this account):<br><a href=\"https:\/\/www.limilabs.com\/blog\/oauth2-password-grant-office365-exchange-imap-pop3-smtp\">https:\/\/www.limilabs.com\/blog\/oauth2-password-grant-office365-exchange-imap-pop3-smtp<\/a><\/p>\n\n\n\n<p><strong>Daemons\/Services:&nbsp;Client credential<\/strong>&nbsp;flow:<br><a href=\"https:\/\/www.limilabs.com\/blog\/oauth2-client-credential-flow-office365-exchange-imap-pop3-smtp\">https:\/\/www.limilabs.com\/blog\/oauth2-client-credential-flow-office365-exchange-imap-pop3-smtp<\/a><\/p>\n\n\n\n<p><strong>Web&nbsp;apps<\/strong>&nbsp;(requires user interaction):<br><a href=\"https:\/\/www.limilabs.com\/blog\/oauth2-web-flow-office365-exchange-imap-pop3-smtp\">https:\/\/www.limilabs.com\/blog\/oauth2-web-flow-office365-exchange-imap-pop3-smtp<\/a><\/p>\n\n\n\n<p><strong>Standalone&nbsp;devices<\/strong>&nbsp;(requires very little interaction):<br><a href=\"https:\/\/www.limilabs.com\/blog\/oauth2-device-flow-office365-exchange-imap-pop3-smtp\">https:\/\/www.limilabs.com\/blog\/oauth2-device-flow-office365-exchange-imap-pop3-smtp<\/a><\/p>\n\n\n\n<p><strong>Desktop&nbsp;apps<\/strong>&nbsp;(requires user interaction):<br><a href=\"https:\/\/www.limilabs.com\/blog\/oauth2-office365-exchange-imap-pop3-smtp\">https:\/\/www.limilabs.com\/blog\/oauth2-office365-exchange-imap-pop3-smtp<\/a><\/p>\n\n\n\n<p>When you&#8217;ve obtained an <strong>access token<\/strong> you simply use it to access shared mailbox:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nstring accessToken = result.AccessToken;\n\nusing (Imap client = new Imap())\n{\n    client.ConnectSSL(&quot;outlook.office365.com&quot;);\n    client.LoginOAUTH2(&quot;invoices@example.com&quot;, accessToken);\n\n    client.SelectInbox();\n\n    List&lt;long&gt; uids = imap.Search(Flag.Unseen);\n    foreach (long uid in uids)\n    {\n        var eml = imap.GetMessageByUID(uid)\n        IMail email = new MailBuilder().CreateFromEml();\n        string subject = email.Subject);\n    }\n    client.Close();\n}\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>Enable IMAP\/POP3 First make sure IMAP \/ POP3 are turned on properly: Enable IMAP \/ POP3 in Office 365 Shared mailbox permissions Make sure you have access to the shared mailbox. Log in to Microsoft 365 admin portal at https:\/\/admin.microsoft.com\/ as an administrator, go to Users\/Active users tab and select shared mailbox: On the Mail [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[28,122,124],"class_list":["post-5802","post","type-post","status-publish","format-standard","hentry","category-mail-dll","tag-imap","tag-office365","tag-shared"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/5802"}],"collection":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/comments?post=5802"}],"version-history":[{"count":26,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/5802\/revisions"}],"predecessor-version":[{"id":6424,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/5802\/revisions\/6424"}],"wp:attachment":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/media?parent=5802"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/categories?post=5802"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/tags?post=5802"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}