Parser Constructor (EmailConnection, ParserSettings) |
Namespace: GroupDocs.Parser
The following example shows how to extract emails from Exchange Server:
// 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()); } } } }