LumiSoft Mail Server User API
Mime Class
Namespaces > LumiSoft.Net.Mime > Mime
Class for creating,parsing,modifing rfc 2822 mime messages.
Syntax

C# | Visual Basic | Managed C++

    public class Mime

    Public Class Mime

    public ref class Mime

Members

All Members | Constructors | Methods | Properties | Fields | Events
Public Protected | Instance Static | Declared Inherited

Icon | Member | Description
--- | --- | ---
| Mime New() | Default constructor.
| Attachments | Gets attachment entities. Entity is considered as attachmnet if: *) Content-Disposition: attachment (RFC 2822 message) *) Content-Disposition: filename = "" is specified (RFC 2822 message) *) Content-Type: name = "" is specified (old RFC 822 message)
| BodyHtml | Gets message body html. Returns null if no body html text specified.
| BodyText | Gets message body text. Returns null if no body text specified.
| CreateSimple(AddressList, AddressList, String, String, String) | Creates simple mime message.
| CreateSimple(AddressList, AddressList, String, String, String, String[]()) | Creates simple mime message with attachments.
| Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
| Finalize() | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
| GetHashCode() | Serves as a hash function for a particular type. GetHashCode() is suitable for use in hashing algorithms and data structures like a hash table. (Inherited from Object.)
| GetType() | Gets the Type of the current instance. (Inherited from Object.)
| MainEntity | Message main(top-level) entity.
| MemberwiseClone() | Creates a shallow copy of the current Object. (Inherited from Object.)
| MimeEntities | Gets all mime entities contained in message, including child entities.
| Parse(Byte[]()) | Parses mime message from byte[] data.
| Parse(String) | Parses mime message from file.
| Parse(Stream) | Parses mime message from stream.
| ToByteData() | Stores mime message to byte[].
| ToFile(String) | Stores mime message to specified file.
| ToStream(Stream) | Stores mime message to specified stream. Stream position stays where mime writing ends.
| ToString() | Returns a String that represents the current Object. (Inherited from Object.)
| ToStringData() | Stores mime message to string.

Remarks

     1Message examples:
     2
     3<B>Simple message:</B>
     4
     5//--- Beginning of message
     6From: sender@domain.com
     7To: recipient@domain.com
     8Subject: Message subject.
     9Content-Type: text/plain
    10
    11Message body text. Bla blaa
    12blaa,blaa.
    13//--- End of message
    14
    15
    16In simple message MainEntity is whole message.
    17
    18<B>Message with attachments:</B>
    19
    20//--- Beginning of message
    21From: sender@domain.com
    22To: recipient@domain.com
    23Subject: Message subject.
    24Content-Type: multipart/mixed; boundary="multipart_mixed"
    25
    26--multipart_mixed    /* text entity */
    27Content-Type: text/plain
    28
    29Message body text. Bla blaa
    30blaa,blaa.
    31--multipart_mixed    /* attachment entity */
    32Content-Type: application/octet-stream
    33
    34attachment_data
    35--multipart_mixed--
    36//--- End of message
    37
    38MainEntity is multipart_mixed entity and text and attachment entities are child entities of MainEntity.

Examples

    1// Parsing example:
    2Mime m = Mime.Parse("message.eml");
    3// Do your stuff with mime

    1// Create simple message with simple way:
    2AddressList from = new AddressList();
    3from.Add(new MailboxAddress("dispaly name","user@domain.com"));
    4AddressList to = new AddressList();
    5to.Add(new MailboxAddress("dispaly name","user@domain.com"));
    6
    7Mime m = Mime.CreateSimple(from,to,"test subject","test body text","");

     1// Creating a new simple message
     2Mime m = new Mime();
     3MimeEntity mainEntity = m.MainEntity;
     4// Force to create From: header field
     5mainEntity.From = new AddressList();
     6mainEntity.From.Add(new MailboxAddress("dispaly name","user@domain.com"));
     7// Force to create To: header field
     8mainEntity.To = new AddressList();
     9mainEntity.To.Add(new MailboxAddress("dispaly name","user@domain.com"));
    10mainEntity.Subject = "subject";
    11mainEntity.ContentType = MediaType_enum.Text_plain;
    12mainEntity.ContentTransferEncoding = ContentTransferEncoding_enum.QuotedPrintable;
    13mainEntity.DataText = "Message body text.";
    14
    15m.ToFile("message.eml");

     1// Creating message with text and attachments
     2Mime m = new Mime();
     3MimeEntity mainEntity = m.MainEntity;
     4// Force to create From: header field
     5mainEntity.From = new AddressList();
     6mainEntity.From.Add(new MailboxAddress("dispaly name","user@domain.com"));
     7// Force to create To: header field
     8mainEntity.To = new AddressList();
     9mainEntity.To.Add(new MailboxAddress("dispaly name","user@domain.com"));
    10mainEntity.Subject = "subject";
    11mainEntity.ContentType = MediaType_enum.Multipart_mixed;
    12
    13MimeEntity textEntity = mainEntity.ChildEntities.Add();
    14textEntity.ContentType = MediaType_enum.Text_plain;
    15textEntity.ContentTransferEncoding = ContentTransferEncoding_enum.QuotedPrintable;
    16textEntity.DataText = "Message body text.";
    17
    18MimeEntity attachmentEntity = mainEntity.ChildEntities.Add();
    19attachmentEntity.ContentType = MediaType_enum.Application_octet_stream;
    20attachmentEntity.ContentDisposition = ContentDisposition_enum.Attachment;
    21attachmentEntity.ContentTransferEncoding = ContentTransferEncoding_enum.Base64;
    22attachmentEntity.ContentDisposition_FileName = "yourfile.xxx";
    23attachmentEntity.DataFromFile("yourfile.xxx");
    24// or
    25attachmentEntity.Data = your_attachment_data;

Inheritance Hierarchy

Object
| Mime

Assembly: LumiSoft.Net Version: 2.0.2636.18419 (Module: LumiSoft.Net)