SharpMimeTools Documented Class Library

SharpMessage Class

[This is preliminary documentation and subject to change.]

This class provides a simplified way of parsing messages.

For a list of all members of this type, see SharpMessage Members.

System.Object
   anmar.SharpMimeTools.SharpMessage

public sealed class SharpMessage

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

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.

Example

Parse a message read from a file enabling the uuencode and ms-tnef decoding and saving attachments to disk.

System.IO.FileStream msg = new System.IO.FileStream("message_file.txt", System.IO.FileMode.Open);
anmar.SharpMimeTools.SharpMessage message = new anmar.SharpMimeTools.SharpMessage(msg, SharpDecodeOptions.Default|SharpDecodeOptions.DecodeTnef|SharpDecodeOptions.UuDecode);
msg.Close();
Console.WriteLine(System.String.Concat("From:    [", message.From, "][", message.FromAddress, "]"));
Console.WriteLine(System.String.Concat("To:      [", message.To, "]"));
Console.WriteLine(System.String.Concat("Subject: [", message.Subject, "]"));
Console.WriteLine(System.String.Concat("Date:    [", message.Date, "]"));
Console.WriteLine(System.String.Concat("Body:    [", message.Body, "]"));
if ( message.Attachments!=null ) {
    foreach ( anmar.SharpMimeTools.SharpAttachment attachment in message.Attachments ) {
        attachment.Save(System.Environment.CurrentDirectory, false);
        Console.WriteLine(System.String.Concat("Attachment: [", attachment.SavedFile.FullName, "]"));
    }
}
This sample shows how simple is to parse an e-mail message read from a file.
System.IO.FileStream msg = new System.IO.FileStream("message_file.txt", System.IO.FileMode.Open);
anmar.SharpMimeTools.SharpMessage message = new anmar.SharpMimeTools.SharpMessage(msg);
msg.Close();
Console.WriteLine(System.String.Concat("From:    [", message.From, "][", message.FromAddress, "]"));
Console.WriteLine(System.String.Concat("To:      [", message.To, "]"));
Console.WriteLine(System.String.Concat("Subject: [", message.Subject, "]"));
Console.WriteLine(System.String.Concat("Date:    [", message.Date, "]"));
Console.WriteLine(System.String.Concat("Body:    [", message.Body, "]"));

Requirements

Namespace: anmar.SharpMimeTools

Assembly: SharpMimeTools (in SharpMimeTools.dll)

See Also

SharpMessage Members | anmar.SharpMimeTools Namespace