Aspose.Email capabilities (specifically MAPI searches on shared mailboxes)

Hi there,

I am investigating whether Aspose.Email for .NET may be a viable option for use in some applications currently in development. The service(s) will be developed as Windows VB.NET service applications and will interact with Microsoft Exchange 2016, specifically with regard to Microsoft Outlook shared mailboxes.

There are some specific functions which I need to be able to perform (and have been able to execute via Outlook Redemption) but curious to know if the same results could possibly be achieved via Aspose.Email?

Namely :

  • Retrieval of Global Address List and certain (extended) MAPI properties per contact / address item in GAL
    1 - PR_DISPLAY_NAME / MAPI property tag &H3001001F
    2 - PR_EMAIL_ADDRESS / MAPI property tag &H39FE001F
    3 - PR_DISPLAY_TYPE / MAPI property tag &H39000003

  • Use of MAPI folders for fast / efficient retrieval of message headers without the need to retrieve individual emails from Exchange
    1 - Connection to mailbox store / search root folder / search folder
    2 - Creation of new search folder and retrieval of email headers (MAPI) for every email in a given date range
    3 - Return (on completion) search folder items as MAPI table
    4 - Query MAPI table into local ADO recordset (i.e. SQL) to break out into individual specified fields
    (would need visibility to ‘standard’ MAPI headers, e.g. MessageID, EntryID, SentOn, Subject, To, CC, SenderEmailAddress etc.) as well as ‘custom’ headers defined via Microsoft MAPI schema tags)

Ultimately the goal is to able to connect to any given shared mailbox and “scan” the contents as quickly as possible. Retrieving individual emails is not an option as some of the mailboxes can be extremely large and all we need are the MAPI headers - we are not interested in the HTML body, attachments etc. Thus MAPI tables are extremely useful in retrieving this kind of information in bulk without bottlenecking the network or dragging down Exchange servers. It also means large volumes of information can be retrieved in a matter of minutes rather than hours (possibly even days, depending on the size of the mailbox)

Can anybody advise if this (or something akin to this) can be achieved using Aspose.Email? And if so, has anybody tried to set up something similar and would there be any code snippets which would help me to get started?

Thanks in advance

@AlanOB,

Following are the comments on your queries about Aspose.Email.

You may use following sample code for accessing the global address list which returns MapiContact collection.

IEWSClient clientCallback = EWSClient.GetEWSClient("https://exchange.domain.com/ews/Exchange.asmx", "username", "password", "");
var Mailboxes = clientCallback.ListMailboxes();

Following article can also be referred for extended mapi properties.
Working with Exchange Extended Attributes of Exchange Items

All the above mentioned properties are available and if available, can be displayed using following sample code:

IEWSClient clientCallback = EWSClient.GetEWSClient("https://exchange.domain.com/ews/Exchange.asmx", "username", "password", "");
var Mailboxes = clientCallback.ListMailboxes();
Console.WriteLine("Iterate through mail boxes");
foreach(var mailBox in Mailboxes)
{
	Console.WriteLine("________________________________________________________");
	foreach(var prop in mailBox.Properties)
	{
		Console.WriteLine("PropertyTagName = " + prop.Value.PropertyTagName);
		Console.WriteLine("Value = " + prop.Value);
	}
}
public static void Run()
{
    try
    {
        IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");
        Console.WriteLine("Downloading all messages from Inbox....");

        ExchangeMailboxInfo mailboxInfo = client.GetMailboxInfo();
        Console.WriteLine("Mailbox URI: " + mailboxInfo.MailboxUri);
        string rootUri = client.GetMailboxInfo().RootUri;
        // List all the folders from Exchange server
        ExchangeFolderInfoCollection folderInfoCollection = client.ListSubFolders(rootUri);
        foreach (ExchangeFolderInfo folderInfo in folderInfoCollection)
        {
            // Call the recursive method to read messages and get sub-folders
            ListSubFolders(client, folderInfo);
        }

        Console.WriteLine("All messages downloaded.");
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
    }
}
private static void ListSubFolders(IEWSClient client, ExchangeFolderInfo folderInfo)
{
    // Create the folder in disk (same name as on IMAP server)
    Console.WriteLine(folderInfo.DisplayName);
    try
    {
        // If this folder has sub-folders, call this method recursively to get messages
        ExchangeFolderInfoCollection folderInfoCollection = client.ListSubFolders(folderInfo.Uri);
        foreach (ExchangeFolderInfo subfolderInfo in folderInfoCollection)
        {
            ListSubFolders(client, subfolderInfo);
        }
    }
    catch (Exception)
    {
    }
}

You may please follow the link below to parse messages based on different criteria.
Filter Messages From Exchange Mailbox

Mapi table is not returned by default however it can be prepared using above mentioned code/article.

Aspose.Email does not provide connectivity with database objects, therefore you may perform database related tasks manually.

Please feel free to write us back if you have any other query in this regard.

1 Like

Thanks a million Kashif!

Certainly looks promising - I shall step up my research!

I may return with further queries but for now I can at least feel optimistic that this might work

Thanks again for the prompt and informative response!

@AlanOB,

You are welcome and thank you for the feedback.