Skip to content

Commit

Permalink
Added FAQ about using shared mailboxes with Office365
Browse files Browse the repository at this point in the history
Improves docs for issue #1770
  • Loading branch information
jstedfast committed Sep 5, 2024
1 parent 7adfbab commit 84de52e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* [Why doesn't ImapFolder.MoveTo() move the message out of the source folder?](#imap-move-does-not-move)
* [How can I mark messages as read using IMAP?](#imap-mark-as-read)
* [How can I re-synchronize the cache for an IMAP folder?](#imap-folder-resync)
* [How can I login using a shared mailbox in Office365?](#office365-shared-mailboxes)

### SmtpClient

Expand Down Expand Up @@ -1731,6 +1732,31 @@ static void ResyncFolder (ImapFolder folder, List<CachedMessageInfo> cache, ref
}
```

### <a href="office365-shared-mailboxes">Q: How can I login using a shared mailbox in Office365?</a>

```csharp
var result = await GetPublicClientOAuth2CredentialsAsync ("IMAP", "[email protected]");

// Note: We always use result.Account.Username instead of `Username` because the user may have selected an alternative account.
var oauth2 = new SaslMechanismOAuth2 (result.Account.Username, result.AccessToken);

using (var client = new ImapClient ()) {
await client.ConnectAsync ("outlook.office365.com", 993, SecureSocketOptions.SslOnConnect);
await client.AuthenticateAsync (oauth2);

// ...
await client.DisconnectAsync (true);
}
```

Notes:

1. The `GetPublicClientOAuth2CredentialsAsync()` method used in this example code snippet can be found in the
[ExchangeOAuth2.md](ExchangeOAuth2.md#desktop-and-mobile-applications) documentation.
2. Some users have reported that they need to use `"[email protected]\\sharedMailboxName"` as their
username instead of `"[email protected]"`.

## SmtpClient

### <a id="smtp-sent-folder">Q: Why doesn't the message show up in the "Sent Mail" folder after sending it?</a>
Expand Down

0 comments on commit 84de52e

Please sign in to comment.