Parser Constructor (EmailConnection)
Initializes a new instance of the Parser class to extract data from a remote email server.

Namespace: GroupDocs.Parser
Assembly: GroupDocs.Parser (in GroupDocs.Parser.dll) Version: 20.8.0
Syntax
public Parser(
	EmailConnection connection
)

Parameters

connection
Type: GroupDocs.Parser.OptionsEmailConnection
The email connection.
Remarks
Examples

The following example shows how to extract emails from Exchange Server:

C#
// Create the connection object for Exchange Web Services protocol 
EmailConnection connection = new EmailEwsConnection(
    "https://outlook.office365.com/ews/exchange.asmx",
    "email@server",
    "password");

// Create an instance of Parser class to extract emails from the remote server
using (Parser parser = new Parser(connection))
{
    // Check if container extraction is supported
    if (!parser.Features.Container)
    {
        Console.WriteLine("Container extraction isn't supported.");
        return;
    }

// Extract email messages from the server
IEnumerable<ContainerItem> emails = parser.GetContainer();

    // Iterate over attachments
    foreach (ContainerItem item in emails)
    {
        // Create an instance of Parser class for email message
        using (Parser emailParser = item.OpenParser())
        {
            // Extract the email text
            using (TextReader reader = emailParser.GetText())
            {
                // Print the email text
                Console.WriteLine(reader == null ? "Text extraction isn't supported." : reader.ReadToEnd());
            }
        }
    }
}
See Also