C# Class Microsoft.Legal.MatterCenter.Utility.MailMimeReader

Reads MIME based emails streams and files.
Inheritance: IDisposable
显示文件 Open project: Microsoft/mattercenter Class Usage Examples

Public Methods

Method Description
ConvertToDateTime ( string date ) : System.DateTime

Tries to convert string to date If there is a run time error, the smallest possible date is returned

ConvertToMailAddress ( string address ) : System.Net.Mail.MailAddress

Tries to convert a string into an email address

DecodeByteArrayToString ( byte byteArray, Encoding byteEncoding ) : string

Converts byte array to string, using decoding as requested

Dispose ( ) : void

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

GetEmail ( Stream emailStream ) : MailMessageParser

Gets an email from the supplied Email Stream and processes it.

GetEmail ( string mailPath ) : MailMessageParser

Gets an email from the supplied Email Stream and processes it.

MailMimeReader ( ) : System

Initializes a new instance of the MailMimeReader class

ProcessReceivedDate ( string headerValue ) : System.DateTime

To process received date from the header field

Protected Methods

Method Description
Dispose ( bool disposing ) : void

Releases unmanaged and - optionally - managed resources.

ReadMultipleLine ( string &response ) : bool

read one line in multiline mode from the Email stream.

Private Methods

Method Description
AddChildPartsToParent ( MailMessageParser child, MailMessageParser parent ) : void

Add all attachments and alternative views from child to the parent

AddMailAddresses ( string addresses, MailAddressCollection addressCollection ) : void

find individual addresses in the string and add it to address collection

ConvertToTransferEncoding ( string transferEncodingString ) : TransferEncoding

converts TransferEncoding as defined in the RFC into a .NET TransferEncoding .NET doesn't know the type "bit8". It is translated here into "bit7", which requires the same kind of processing (none).

ParentBoundaryFound ( string response, string parentBoundaryStart, string parentBoundaryEnd, MimeEntityReturnCode &boundaryMimeReturnCode ) : bool

Check if the response line received is a parent boundary

ProcessDelimitedBody ( MailMessageParser message, string boundaryStart, string parentBoundaryStart, string parentBoundaryEnd ) : MimeEntityReturnCode

Processes the delimited body of Mail Mime Entity.

ProcessHeaderField ( MailMessageParser message, string headerField ) : void

Convert one MIME header field and update message accordingly

ProcessMimeEntity ( MailMessageParser message, string parentBoundaryStart ) : MimeEntityReturnCode

Process a MIME entity A MIME entity consists of header and body. Separator lines in the body might mark children MIME entities

RemoveBrackets ( string parameterString ) : string

removes leading '<' and trailing '>' if both exist

SaveAttachment ( MailMessageParser message ) : void

each attachment is stored in its own MIME entity and read into this entity's ContentStream. SaveAttachment creates an attachment out of the ContentStream and attaches it to the parent MIME entity.

SaveMessageBody ( MailMessageParser message, string contentString ) : void

Copies the content found for the MIME entity to the MailMessageParser body and creates a stream which can be used to create attachments and alternative views.

Method Details

ConvertToDateTime() public method

Tries to convert string to date If there is a run time error, the smallest possible date is returned
public ConvertToDateTime ( string date ) : System.DateTime
date string string to be converted to Date object
return System.DateTime

ConvertToMailAddress() public static method

Tries to convert a string into an email address
public static ConvertToMailAddress ( string address ) : System.Net.Mail.MailAddress
address string string mail address to parse
return System.Net.Mail.MailAddress

DecodeByteArrayToString() public static method

Converts byte array to string, using decoding as requested
public static DecodeByteArrayToString ( byte byteArray, Encoding byteEncoding ) : string
byteArray byte Stream byte array.
byteEncoding System.Text.Encoding byte encoding to use
return string

Dispose() public method

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public Dispose ( ) : void
return void

Dispose() protected method

Releases unmanaged and - optionally - managed resources.
protected Dispose ( bool disposing ) : void
disposing bool true to release both managed and unmanaged resources; false to release only unmanaged resources.
return void

GetEmail() public method

Gets an email from the supplied Email Stream and processes it.
public GetEmail ( Stream emailStream ) : MailMessageParser
emailStream Stream The email stream object
return MailMessageParser

GetEmail() public method

Gets an email from the supplied Email Stream and processes it.
public GetEmail ( string mailPath ) : MailMessageParser
mailPath string string that designates the path to a .EML file
return MailMessageParser

MailMimeReader() public method

Initializes a new instance of the MailMimeReader class
public MailMimeReader ( ) : System
return System

ProcessReceivedDate() public method

To process received date from the header field
public ProcessReceivedDate ( string headerValue ) : System.DateTime
headerValue string Header value from the headers of the mail
return System.DateTime

ReadMultipleLine() protected method

read one line in multiline mode from the Email stream.
protected ReadMultipleLine ( string &response ) : bool
response string line received
return bool