Connecting to Exchange with IMAP

I am trying to use Aspose to connect to an Exchange Server 2010 to get into a mail box and fetch mails.

How do I check mails in public folders?

If I use ListFolders(), it only lists the folders in the mail box, not the Public Folders.

Hi Robert,

Thank you for writing to Aspose support team.
IEWSClient can be used to fetch messages from the public folders. Please give a try to the following sample code and share the feedback.

static void Email_711917()
{
    IEWSClient client = GetAsposeEWSClientTest3();
    ExchangeFolderInfoCollection coll = client.ListPublicFolders();
    
    foreach(ExchangeFolderInfo FolderInfo in coll)
    {
        ExchangeMessageInfoCollection MsgColl = client.ListMessages(FolderInfo.Uri);
        
        foreach(ExchangeMessageInfo MessageInfo in MsgColl)
        {
            MailMessage msg = client.FetchMessage(MessageInfo.UniqueUri);
        }
    }
}

public static IEWSClient GetAsposeEWSClientTest3()
{
    const string mailboxUri = "https://exchange.domain.com/ews/Exchange.asmx";
    const string domain = @"";
    const string username = @"username";
    const string password = @"password";
    NetworkCredential credentials = new NetworkCredential(username, password, domain);
    IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials);
    return client;
}

Thanks. That does the trick.

You are welcome.