Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active December 12, 2023 23:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aspose-com-gists/d761d651a93cbc11e1faec93f2e29be8 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/d761d651a93cbc11e1faec93f2e29be8 to your computer and use it in GitHub Desktop.
Read Emails from Shared Mailbox on Exchange Server in C# .NET
const string mailboxUri = "<HOST>";
const string domain = "";
const string username = "<EMAIL ADDRESS>";
const string password = "<PASSWORD>";
const string sharedEmail = "<SHARED EMAIL ADDRESS>";
// Setup credentials
NetworkCredential credentials = new NetworkCredential(username, password, domain);
// Connect to server
IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials);
// Get email items
string[] items = client.ListItems(sharedEmail, "Inbox");
// Loop through emails and fetch each message
foreach (string item in items)
{
MapiMessage msg = client.FetchItem(item);
Console.WriteLine("Subject:" + msg.Subject);
}
client.Dispose();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment