Rebex Mail for .NET Features - MIME

MIME is the current standard which defines the format of internat mail messages.
We offer two sets of classes to manipulate MIME messages - simple interface
in Rebex.Mail namespace and advanced low-level interface in Rebex.Mime.
The MailMessage class
The core of the simple interface is the MailMessage class. It is simple yet powerful
and provides straightforward access to commonly used features of MIME. This should be
enough for 95% of usage scenarios.
Instances of MailMessage class can be sent via SMTP,
downloaded via POP3 or downloaded/stored
via IMAP components.
Features of MailMessage include:
- Reads mail message from a disk file or stream.
- Writes mail message to a disk file or stream.
- New MailMessage can be built from scratch in just a few lines of code.
- Reads and writes Base64, Quoted-Printable, 7bit, 8bit and binary encoded messages and attachments.
- Reads legacy mail messages with UUEncoded attachments.
- Robust parser accepts many damaged or partially invalid messages.
- Support for international character sets.
- Automatic characted set detection - no need to care about different character sets.
- Easy-to-use MailMessage class suitable for most scenarios.
- Built on top of MimeMessage class, and can be converted to it for direct access to mail structure.
- Simple access to address-list headers such as From, To, CC, BCC through MailAddress and MailAddressColleciton classes.
- Simple access to complex headers such as Message-ID, In-Reply-To through dedicated classes.
- Simple access to other most common headers such as Subject, Priority and Date.
- Direct access to any header in the message through Headers collection.
- Plain text and/or HTML body in a message accessed through string properties.
- Access to arbitrary number of alternate body views through AlternateView and AlternateViewCollection classes.
- Support for linked resources such as pictures or CSS in alternate body views.
- Alternate body views can saved to a file or stream and added from a file or stream.
- Access to arbitrary number of attachments through AlternateView and AlternateViewCollection classes.
- Attachments can saved to a file or stream and added from a file or stream.
- Supports serialization.
- Aims for compliance with RFC 2045, 2046, 2047, 2048, 2049, 2822, etc., except when current practise deviates from these.
The MimeMessage Class
The MimeMessage class from Rebex.Mime namespace provides advanced low-level access to the mail structure
and its aspects. It should be used when you have special needs for internal representation of MIME messages
that are not supported by the MailMessage class, or if you need to work with MIME files that don't represent
mail, such as MHT files used for saving complete web pages by Internet Explorer.
MimeMessage also allows you to read a MIME message, modify few properties of it and save it in a form
that nearly matches the original.
Instances of MimeMessage class can also be sent via SMTP,
downloaded via POP3 or downloaded/stored
via IMAP components.
Features of MimeMessage class include:
- Reads MIME messages from a disk file or stream.
- Writes MIME messages to a disk file or stream.
- Direct access to all message headers.
- Direct access to all message entities.
- Read, write, build and process complex multipart MIME messages.
- Specify body parts encoding, or let the component handle it automatically.
- Supports Base64, Quoted-Printable, 7bit, 8bit and binary encoded body parts.
- Access to preamble and epilogue of multipart entities.
- Supports serialization.
While we tried hard to be compliant with relevant RFCs, current practise in internet mail often
deviates from these standards. In fact, sometimes being compliant can severely hinder
interoperability with existing software. Interoperability was therefore the highest priority.
(For example, being compliant with RFC 2231 would lead to incompatibility with Microsoft Outlook,
Outlook Express, and possibly a number of other mail agents as well. So even though Rebex Mail
is able to parse RFC2231-compliant messages, it does not produce them.)
Sample usage
This sample demostrates reading a mail message from a disk, accessing its properties and sending it via SMTP.
C#
using Rebex.Net;
using Rebex.Mail;
MailMessage message = new MailMessage();
msg.Load(@"c:\temp\message.eml");
Console.Write(
"Sending mail from '{0}' to '{1}' with subject '{2}'"
message.From,
message.To,
message.Subject
);
Smtp.Send(message, "smtp.example.org");
VB.NET
Imports Rebex.Net
Imports Rebex.Mail
Dim message As New MailMessage
msg.Load("c:\temp\message.eml")
Console.Write( _
"Sending mail from '{0}' to '{1}' with subject '{2}'" _
message.From, _
message.To, _
message.Subject)
Smtp.Send(message, "smtp.example.org")