C# Класс anmar.SharpMimeTools.SharpMessage

This class provides a simplified way of parsing messages.
All the mime complexity is handled internally and all the content is exposed parsed and decoded. The code takes care of comments, RFC 2047, encodings, etc.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
GetHeaderField ( System name ) : System.String

Returns the requested header field body.

The value if present is uncommented and decoded (RFC 2047).
If the requested field is not present in this instance, System.String.Empty is returned instead.

SetUrlBase ( System attachmentsurl ) : void

Set the URL used to reference embedded parts from the HTML body (as specified on RFC2392)

The supplied URL will be replaced with the following tokens for each attachment:

  • [MessageID]: Will be replaced with the MessageID of the current instance.
  • [ContentID]: Will be replaced with the anmar.SharpMimeTools.SharpAttachment.ContentID of the attachment.
  • [Name]: Will be replaced with the anmar.SharpMimeTools.SharpAttachment.Name of the attachment (or with System.IO.FileInfo.Name from anmar.SharpMimeTools.SharpAttachment.SavedFile if the instance has been already saved to disk).
SharpMessage ( System message ) : System

Initializes a new instance of the anmar.SharpMimeTools.SharpMessage class based on the supplied System.IO.Stream.

The message content is automatically parsed.

SharpMessage ( System message, SharpDecodeOptions options ) : System

Initializes a new instance of the anmar.SharpMimeTools.SharpMessage class based on the supplied System.IO.Stream.

SharpMessage ( System message, SharpDecodeOptions options, System path ) : System

Initializes a new instance of the anmar.SharpMimeTools.SharpMessage class based on the supplied System.IO.Stream.

SharpMessage ( System message, SharpDecodeOptions options, System path, System preferredtextsubtype ) : System

Initializes a new instance of the anmar.SharpMimeTools.SharpMessage class based on the supplied System.IO.Stream.

SharpMessage ( System message, anmar types, SharpDecodeOptions options, System path, System preferredtextsubtype ) : System

Initializes a new instance of the anmar.SharpMimeTools.SharpMessage class based on the supplied System.IO.Stream.

SharpMessage ( System message, anmar types, bool html ) : System

Initializes a new instance of the anmar.SharpMimeTools.SharpMessage class based on the supplied System.IO.Stream.

SharpMessage ( System message, anmar types, bool html, System path ) : System

Initializes a new instance of the anmar.SharpMimeTools.SharpMessage class based on the supplied System.IO.Stream.

SharpMessage ( System message, anmar types, bool html, System path, System preferredtextsubtype ) : System

Initializes a new instance of the anmar.SharpMimeTools.SharpMessage class based on the supplied System.IO.Stream.

SharpMessage ( System message, bool attachments, bool html ) : System

Initializes a new instance of the anmar.SharpMimeTools.SharpMessage class based on the supplied System.IO.Stream.

When the attachments parameter is true it's equivalent to adding anmar.SharpMimeTools.MimeTopLevelMediaType.application, anmar.SharpMimeTools.MimeTopLevelMediaType.audio, anmar.SharpMimeTools.MimeTopLevelMediaType.image, anmar.SharpMimeTools.MimeTopLevelMediaType.video to the allowed anmar.SharpMimeTools.MimeTopLevelMediaType.
anmar.SharpMimeTools.MimeTopLevelMediaType.text, anmar.SharpMimeTools.MimeTopLevelMediaType.multipart and anmar.SharpMimeTools.MimeTopLevelMediaType.message are allowed in any case.

In order to have better control over what is parsed, see the other contructors.

SharpMessage ( System message, bool attachments, bool html, System path ) : System

Initializes a new instance of the anmar.SharpMimeTools.SharpMessage class based on the supplied System.IO.Stream.

When the attachments parameter is true it's equivalent to adding anmar.SharpMimeTools.MimeTopLevelMediaType.application, anmar.SharpMimeTools.MimeTopLevelMediaType.audio, anmar.SharpMimeTools.MimeTopLevelMediaType.image, anmar.SharpMimeTools.MimeTopLevelMediaType.video to the allowed anmar.SharpMimeTools.MimeTopLevelMediaType.
anmar.SharpMimeTools.MimeTopLevelMediaType.text, anmar.SharpMimeTools.MimeTopLevelMediaType.multipart and anmar.SharpMimeTools.MimeTopLevelMediaType.message are allowed in any case.

In order to have better control over what is parsed, see the other contructors.

SharpMessage ( System message, bool attachments, bool html, System path, System preferredtextsubtype ) : System

Initializes a new instance of the anmar.SharpMimeTools.SharpMessage class based on the supplied System.IO.Stream.

When the attachments parameter is true it's equivalent to adding anmar.SharpMimeTools.MimeTopLevelMediaType.application, anmar.SharpMimeTools.MimeTopLevelMediaType.audio, anmar.SharpMimeTools.MimeTopLevelMediaType.image, anmar.SharpMimeTools.MimeTopLevelMediaType.video to the allowed anmar.SharpMimeTools.MimeTopLevelMediaType.
anmar.SharpMimeTools.MimeTopLevelMediaType.text, anmar.SharpMimeTools.MimeTopLevelMediaType.multipart and anmar.SharpMimeTools.MimeTopLevelMediaType.message are allowed in any case.

In order to have better control over what is parsed, see the other contructors.

Приватные методы

Метод Описание
ParseMessage ( System stream, anmar types, SharpDecodeOptions options, System preferredtextsubtype, System path ) : void
ParseMessage ( anmar part, anmar types, bool html, SharpDecodeOptions options, System preferredtextsubtype, System path ) : void
ReplaceUrlTokens ( System url, anmar attachment ) : System.String
UuDecode ( System path ) : void

Описание методов

GetHeaderField() публичный Метод

Returns the requested header field body.
The value if present is uncommented and decoded (RFC 2047).
If the requested field is not present in this instance, System.String.Empty is returned instead.
public GetHeaderField ( System name ) : System.String
name System
Результат System.String

SetUrlBase() публичный Метод

Set the URL used to reference embedded parts from the HTML body (as specified on RFC2392)
The supplied URL will be replaced with the following tokens for each attachment:
  • [MessageID]: Will be replaced with the MessageID of the current instance.
  • [ContentID]: Will be replaced with the anmar.SharpMimeTools.SharpAttachment.ContentID of the attachment.
  • [Name]: Will be replaced with the anmar.SharpMimeTools.SharpAttachment.Name of the attachment (or with System.IO.FileInfo.Name from anmar.SharpMimeTools.SharpAttachment.SavedFile if the instance has been already saved to disk).
public SetUrlBase ( System attachmentsurl ) : void
attachmentsurl System URL used to reference embedded parts from the HTML body.
Результат void

SharpMessage() публичный Метод

Initializes a new instance of the anmar.SharpMimeTools.SharpMessage class based on the supplied System.IO.Stream.
The message content is automatically parsed.
public SharpMessage ( System message ) : System
message System that contains the message content
Результат System

SharpMessage() публичный Метод

Initializes a new instance of the anmar.SharpMimeTools.SharpMessage class based on the supplied System.IO.Stream.
public SharpMessage ( System message, SharpDecodeOptions options ) : System
message System that contains the message content
options SharpDecodeOptions to determine how to do the decoding (must be combined as a bit map).
Результат System

SharpMessage() публичный Метод

Initializes a new instance of the anmar.SharpMimeTools.SharpMessage class based on the supplied System.IO.Stream.
public SharpMessage ( System message, SharpDecodeOptions options, System path ) : System
message System that contains the message content
options SharpDecodeOptions to determine how to do the decoding (must be combined as a bit map).
path System A specifying the path on which to save the attachments found.
Результат System

SharpMessage() публичный Метод

Initializes a new instance of the anmar.SharpMimeTools.SharpMessage class based on the supplied System.IO.Stream.
public SharpMessage ( System message, SharpDecodeOptions options, System path, System preferredtextsubtype ) : System
message System that contains the message content
options SharpDecodeOptions to determine how to do the decoding (must be combined as a bit map).
path System A specifying the path on which to save the attachments found.
preferredtextsubtype System A specifying the subtype to select for text parts that contain aternative content (plain, html, ...). Specify the null reference to maintain the default behavior (prefer whatever the originator sent as the preferred part). If there is not a text part with this subtype, the default one is used.
Результат System

SharpMessage() публичный Метод

Initializes a new instance of the anmar.SharpMimeTools.SharpMessage class based on the supplied System.IO.Stream.
public SharpMessage ( System message, anmar types, SharpDecodeOptions options, System path, System preferredtextsubtype ) : System
message System that contains the message content
types anmar A value that specifies the allowed Mime-Types to being decoded.
options SharpDecodeOptions to determine how to do the decoding (must be combined as a bit map).
path System A specifying the path on which to save the attachments found.
preferredtextsubtype System A specifying the subtype to select for text parts that contain aternative content (plain, html, ...). Specify the null reference to maintain the default behavior (prefer whatever the originator sent as the preferred part). If there is not a text part with this subtype, the default one is used.
Результат System

SharpMessage() публичный Метод

Initializes a new instance of the anmar.SharpMimeTools.SharpMessage class based on the supplied System.IO.Stream.
public SharpMessage ( System message, anmar types, bool html ) : System
message System that contains the message content
types anmar A value that specifies the allowed Mime-Types to being decoded.
html bool true to allow HTML content; false to ignore the html content.
Результат System

SharpMessage() публичный Метод

Initializes a new instance of the anmar.SharpMimeTools.SharpMessage class based on the supplied System.IO.Stream.
public SharpMessage ( System message, anmar types, bool html, System path ) : System
message System that contains the message content
types anmar A value that specifies the allowed Mime-Types to being decoded.
html bool true to allow HTML content; false to ignore the html content.
path System A specifying the path on which to save the attachments found.
Результат System

SharpMessage() публичный Метод

Initializes a new instance of the anmar.SharpMimeTools.SharpMessage class based on the supplied System.IO.Stream.
public SharpMessage ( System message, anmar types, bool html, System path, System preferredtextsubtype ) : System
message System that contains the message content
types anmar A value that specifies the allowed Mime-Types to being decoded.
html bool true to allow HTML content; false to ignore the html content.
path System A specifying the path on which to save the attachments found.
preferredtextsubtype System A specifying the subtype to select for text parts that contain aternative content (plain, html, ...). Specify the null reference to maintain the default behavior (prefer whatever the originator sent as the preferred part). If there is not a text part with this subtype, the default one is used.
Результат System

SharpMessage() публичный Метод

Initializes a new instance of the anmar.SharpMimeTools.SharpMessage class based on the supplied System.IO.Stream.
When the attachments parameter is true it's equivalent to adding anmar.SharpMimeTools.MimeTopLevelMediaType.application, anmar.SharpMimeTools.MimeTopLevelMediaType.audio, anmar.SharpMimeTools.MimeTopLevelMediaType.image, anmar.SharpMimeTools.MimeTopLevelMediaType.video to the allowed anmar.SharpMimeTools.MimeTopLevelMediaType.
anmar.SharpMimeTools.MimeTopLevelMediaType.text, anmar.SharpMimeTools.MimeTopLevelMediaType.multipart and anmar.SharpMimeTools.MimeTopLevelMediaType.message are allowed in any case.

In order to have better control over what is parsed, see the other contructors.
public SharpMessage ( System message, bool attachments, bool html ) : System
message System that contains the message content
attachments bool true to allow attachments; false to skip them.
html bool true to allow HTML content; false to ignore the html content.
Результат System

SharpMessage() публичный Метод

Initializes a new instance of the anmar.SharpMimeTools.SharpMessage class based on the supplied System.IO.Stream.
When the attachments parameter is true it's equivalent to adding anmar.SharpMimeTools.MimeTopLevelMediaType.application, anmar.SharpMimeTools.MimeTopLevelMediaType.audio, anmar.SharpMimeTools.MimeTopLevelMediaType.image, anmar.SharpMimeTools.MimeTopLevelMediaType.video to the allowed anmar.SharpMimeTools.MimeTopLevelMediaType.
anmar.SharpMimeTools.MimeTopLevelMediaType.text, anmar.SharpMimeTools.MimeTopLevelMediaType.multipart and anmar.SharpMimeTools.MimeTopLevelMediaType.message are allowed in any case.

In order to have better control over what is parsed, see the other contructors.
public SharpMessage ( System message, bool attachments, bool html, System path ) : System
message System that contains the message content
attachments bool true to allow attachments; false to skip them.
html bool true to allow HTML content; false to ignore the html content.
path System A specifying the path on which to save the attachments found.
Результат System

SharpMessage() публичный Метод

Initializes a new instance of the anmar.SharpMimeTools.SharpMessage class based on the supplied System.IO.Stream.
When the attachments parameter is true it's equivalent to adding anmar.SharpMimeTools.MimeTopLevelMediaType.application, anmar.SharpMimeTools.MimeTopLevelMediaType.audio, anmar.SharpMimeTools.MimeTopLevelMediaType.image, anmar.SharpMimeTools.MimeTopLevelMediaType.video to the allowed anmar.SharpMimeTools.MimeTopLevelMediaType.
anmar.SharpMimeTools.MimeTopLevelMediaType.text, anmar.SharpMimeTools.MimeTopLevelMediaType.multipart and anmar.SharpMimeTools.MimeTopLevelMediaType.message are allowed in any case.

In order to have better control over what is parsed, see the other contructors.
public SharpMessage ( System message, bool attachments, bool html, System path, System preferredtextsubtype ) : System
message System that contains the message content
attachments bool true to allow attachments; false to skip them.
html bool true to allow HTML content; false to ignore the html content.
path System A specifying the path on which to save the attachments found.
preferredtextsubtype System A specifying the subtype to select for text parts that contain aternative content (plain, html, ...). Specify the null reference to maintain the default behavior (prefer whatever the originator sent as the preferred part). If there is not a text part with this subtype, the default one is used.
Результат System