EmailContainer Class
Provides a container for email servers.
Inheritance Hierarchy
SystemObject
  GroupDocs.Parser.ContainersEmailContainer

Namespace: GroupDocs.Parser.Containers
Assembly: GroupDocs.Parser (in GroupDocs.Parser.dll) Version: 19.5
Syntax
public sealed class EmailContainer : IContainer, 
	IDisposable

The EmailContainer type exposes the following members.

Constructors
  NameDescription
Public methodEmailContainer
Initializes a new instance of the EmailContainer class.
Properties
  NameDescription
Public propertyConnectionInfo
Gets an information for connection with email server.
Public propertyEntities
Gets a collection of container's entities.
Methods
  NameDescription
Public methodDispose
Releases the unmanaged resources used by the container.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the type of the current instance.
(Inherited from Object.)
Public methodOpenEntityStream
Opens a stream with the content of the container's entity.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Examples

To retrieve a list of all emails Entities property is used:

C#
// Create connection info
var info = EmailConnectionInfo.CreateEwsConnectionInfo(
    @"https://outlook.office365.com/ews/exchange.asmx", 
    "username", 
    "password");
// Create an email container
using (var container = new EmailContainer(info)) {
  // Iterate over emails
  foreach(var entity in container.Entities) {
    Console.WriteLine("Folder: " + entity.Path.ToString()); // A folder at server
    Console.WriteLine("Subject: " + entity[MetadataNames.Subject]); // A subject of email
    Console.WriteLine("From: " + entity[MetadataNames.EmailFrom]); // "From" address
    Console.WriteLine("To: " + entity[MetadataNames.EmailTo]); // "To" addresses
  }
}

To retrieve an email OpenEntityStream method is used:

C#
// Create connection info
var info = EmailConnectionInfo.CreateEwsConnectionInfo(
    @"https://outlook.office365.com/ews/exchange.asmx",
    "username",
    "password");
// Create an email container
using (var container = new EmailContainer(info)) {
  // Iterate over emails
  foreach(var entity in container.Entities) {
    // Create a stream with content of email
    var stream = container.OpenEntityStream(entity); // or var stream = entity.OpenStream();
    // Create a text extractor for email
    using(var extractor = new EmailTextExtractor(stream)) { 
      // Extract all the text from email
      Console.WriteLine(extractor.ExtractAll());
    }
  }
}
See Also