• DR-IT Software
  • Products
  • Documentation
  • Product page
  • Examples
  • API reference
  • Support
Show / Hide Table of Contents

Class MailMessageConverter

Provides conversion methods between the various mail message formats supported by the library (MSG, EML, MBOX, PST, MIME, MAPI).

Inheritance
object
MailMessageConverter
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: DRIT.Mail.Conversion
Assembly: DRIT.Mail.dll
Syntax
public static class MailMessageConverter

Methods

View Source

EmlToMapiMessage(Stream, MailMessageFormat)

Converts an EML stream to a MapiMessage in the specified target format.

Declaration
public static MapiMessage EmlToMapiMessage(Stream emlStream, MailMessageFormat targetFormat)
Parameters
Type Name Description
Stream emlStream

The stream containing the EML data.

MailMessageFormat targetFormat

The desired output message format.

Returns
Type Description
MapiMessage

The converted MapiMessage.

Exceptions
Type Condition
ArgumentNullException

Thrown when emlStream is null.

View Source

EmlToMapiMessage(string, MailMessageFormat)

Converts an EML file to a MapiMessage in the specified target format.

Declaration
public static MapiMessage EmlToMapiMessage(string emlFileName, MailMessageFormat targetFormat)
Parameters
Type Name Description
string emlFileName

The path of the EML file to read.

MailMessageFormat targetFormat

The desired output message format.

Returns
Type Description
MapiMessage

The converted MapiMessage.

Exceptions
Type Condition
ArgumentNullException

Thrown when emlFileName is null.

View Source

MapiMessageToEml(MapiMessage, Stream)

Converts a MapiMessage to EML format and writes it to the supplied stream.

Declaration
public static void MapiMessageToEml(MapiMessage message, Stream emlStream)
Parameters
Type Name Description
MapiMessage message

The MAPI message to convert.

Stream emlStream

The stream to write the EML data to.

Exceptions
Type Condition
ArgumentNullException

Thrown when message or emlStream is null.

View Source

MapiMessageToEml(MapiMessage, string)

Converts a MapiMessage to EML format and writes it to a file.

Declaration
public static void MapiMessageToEml(MapiMessage message, string emlFileName)
Parameters
Type Name Description
MapiMessage message

The MAPI message to convert.

string emlFileName

The path of the EML file to create.

Exceptions
Type Condition
ArgumentNullException

Thrown when emlFileName is null.

View Source

MapiMessageToHtml(MapiMessage, Stream)

Converts a MapiMessage to HTML format and writes it to the supplied stream. The output includes message headers (From, To, Cc, Subject, Date) and the HTML body.

Declaration
public static void MapiMessageToHtml(MapiMessage message, Stream htmlStream)
Parameters
Type Name Description
MapiMessage message

The MAPI message to convert.

Stream htmlStream

The stream to write the HTML data to.

Exceptions
Type Condition
ArgumentNullException

Thrown when message or htmlStream is null.

View Source

MapiMessageToHtml(MapiMessage, string)

Converts a MapiMessage to HTML format and writes it to a file.

Declaration
public static void MapiMessageToHtml(MapiMessage message, string htmlFileName)
Parameters
Type Name Description
MapiMessage message

The MAPI message to convert.

string htmlFileName

The path of the HTML file to create.

Exceptions
Type Condition
ArgumentNullException

Thrown when htmlFileName is null.

View Source

MapiMessageToMime(MapiMessage)

Converts a MapiMessage to a MimeMessage.

Declaration
public static MimeMessage MapiMessageToMime(MapiMessage message)
Parameters
Type Name Description
MapiMessage message

The MAPI message to convert.

Returns
Type Description
MimeMessage

The equivalent MIME message.

View Source

MapiMessagesToMbox(IEnumerable<MapiMessage>, Stream)

Writes MapiMessage objects to an MBOX stream. Each message is converted to MIME via MapiMessageToMime(MapiMessage) and then written with an MBOX From line and mboxrd quoting.

Declaration
public static void MapiMessagesToMbox(IEnumerable<MapiMessage> messages, Stream mboxStream)
Parameters
Type Name Description
IEnumerable<MapiMessage> messages

The messages to write.

Stream mboxStream

The stream to write the MBOX data to.

View Source

MboxToMapiMessages(Stream, MailMessageFormat)

Converts all messages in an MBOX stream to MapiMessage objects. Each message is read from the MBOX stream, parsed as MIME, then converted to a MapiMessage in the specified target format.

Declaration
public static IReadOnlyList<MapiMessage> MboxToMapiMessages(Stream mboxStream, MailMessageFormat targetFormat)
Parameters
Type Name Description
Stream mboxStream

The MBOX stream to read from.

MailMessageFormat targetFormat

The target format for the converted messages (e.g. Msg).

Returns
Type Description
IReadOnlyList<MapiMessage>

A read-only list of converted MapiMessage objects.

View Source

MsgToPstMessage(MsgMapiMessage, CompositeFolder)

Converts an MSG message to a PST-backed message stored inside the specified folder.

Declaration
public static PstMapiMessage MsgToPstMessage(MsgMapiMessage msgMessage, CompositeFolder targetFolder)
Parameters
Type Name Description
MsgMapiMessage msgMessage

The MSG message to convert.

CompositeFolder targetFolder

The PST folder that will store the converted message.

Returns
Type Description
PstMapiMessage

The newly created PstMapiMessage.

Exceptions
Type Condition
ArgumentNullException

Thrown when msgMessage or targetFolder is null.

View Source

PstMessageToMsg(MapiMessage, Stream)

Converts a PST-backed MapiMessage to MSG format and writes it to the supplied stream.

Declaration
public static void PstMessageToMsg(MapiMessage pstMessage, Stream msgStream)
Parameters
Type Name Description
MapiMessage pstMessage

The PST message to convert.

Stream msgStream

The stream to write the MSG data to.

Exceptions
Type Condition
ArgumentNullException

Thrown when pstMessage or msgStream is null.

View Source

PstMessageToMsg(MapiMessage, string)

Converts a PST-backed MapiMessage to MSG format and writes it to a file.

Declaration
public static void PstMessageToMsg(MapiMessage pstMessage, string msgFileName)
Parameters
Type Name Description
MapiMessage pstMessage

The PST message to convert.

string msgFileName

The path of the MSG file to create.

Exceptions
Type Condition
ArgumentNullException

Thrown when msgFileName is null.

  • View Source
Back to top

DR-IT Software documentation

DR-IT Software · Products · Documentation index · Product page · Downloads · Support · Licensing

Generated by DocFX