PowerTCP Mail for .NET
MIME vs Non-MIME
Send comments on this topic.



Glossary Item Box

Email messages can generally be separated into two broad categories:

Although it is possible to create an email message combining elements which are both non-MIME and MIME, it is highly recommended that this is not done. The recommended way to create an email message is to first determine the type of message you wish to send (non-MIME or MIME), then construct the message accordingly

Non-MIME messages

A non-MIME message refers to any message that is created in the original format defined in RFC822. These messages are generally made up of simple text and Uuencoded or Yencoded attachments.

MIME messages

MIME (Multipurpose Internet Mail Extensions) was defined to expand upon the original RFC822 message structure's ability to transport files and the inability to create a complex-multipart message. These types of messages are usually recognizable by the "MIME-VERSION : 1.0" header line and the MIME-boundary separating the parts of the message.

Since almost all email readers today are MIME compatible, it is recommended to create all messages as MIME messages. Create a non-MIME messages only if it is likely that the mail reader used to receive the message will be unable to read MIME.

PowerTCP Mail for .NET's Implementation

When using PowerTCP Mail for .NET, email messages are represented by the MessageStream object. NonMime represents all non-MIME message parts. Use this property to create a non-MIME message. Parts contains collections of all MIME message parts. Add to these collections to create a MIME message. In addition, the MessageStream object contains high-level properties to help in the creation of MIME messages. The Text property represents MIME text and the Attachments property reflects all recursive MIME attachments in the message.

The following table compares creating a non-MIME message to a MIME message using PowerTCP Mail for .NET.

  When creating a Non-MIME message When creating a MIME message.
To add text Set NonMime.Text Either set Text or use MessageStream.Parts.Simple.Add
To add attachments Use AttachmentStreams.Add Use Add or MimeAttachmentStreams.Add
Available attachment encoding. Uuencoded only (when creating). Base-64, Quoted-Printable
To add messages Not possible. Use MessageStreams.Add
Attachment represented by AttachmentStream MimeAttachmentStream

Example 1: Creating a non-MIME message.

This first example demonstrates creating a message which is entirely non-MIME.

C# Copy Code
// Create a new message stream.
MessageStream nonMimeMessage = new MessageStream();

// Specify the recipient.
nonMimeMessage.To.Add(new MailAddress("you@yourserver.com"));

// Specify the sender.
nonMimeMessage.From = new MailAddress("test@dart.com");

// Add a "Subject:" header line.
nonMimeMessage.Subject = "non-MIME message";

// Add some text.
nonMimeMessage.NonMime.Text = "This is a non-MIME message";

// Add an attachment. For the purposes of this example "file1.txt" is a simple
// text file containing the words "This is a text file.".
nonMimeMessage.NonMime.Attachments.Add(new AttachmentStream("C:\\test\\file1.txt"));
                        
// Send the message.
smtp1.Server = "mail.test.com";
smtp1.Send(nonMimeMessage);
Visual Basic Copy Code
' Create a new message stream.
Dim nonMimeMessage as new MessageStream()

' Specify the recipient.
nonMimeMessage.To.Add(new MailAddress("you@yourserver.com"))

' Specify the sender.
nonMimeMessage.From = new MailAddress("test@dart.com")

' Add a "Subject:" header line.
nonMimeMessage.Subject = "non-MIME message"

' Add some text.
nonMimeMessage.NonMime.Text = "This is a non-MIME message"

' Add an attachment. For the purposes of this example "file1.txt" is a simple
' text file containing the words "This is a text file.".
nonMimeMessage.NonMime.Attachments.Add(new AttachmentStream("C:\test\file1.txt"))
                        
' Send the message.
Smtp1.Server = "mail.test.com"
Smtp1.Send(nonMimeMessage)

The code above will create a message which looks like the following (this is the encoded view):

To: <you@yourserver.com>
From: <test@dart.com>
Date: 19 Jul 2002 12:38:18 -0400
Subject: non-MIME message

This is a non-MIME message
begin 666 file1.txt
45&AI<r!i<r!a('1E<W0@9FEL92X*
end

Example 2: Creating a MIME message.

The second example demonstrates creating a message which is entirely MIME.

C# Copy Code
// Create a new MessageStream.
MessageStream mimeMessage = new MessageStream();

// Specify the recipient.
mimeMessage.To.Add("you@yourserver.com");

// Specify the sender.
mimeMessage.From = new MailAddress("test@dart.com");

// Add a "Subject:" header line.
mimeMessage.Subject = "MIME message";

// Add some text.
mimeMessage.Text = "This is a mime message";

// Add an attachment. For the purposes of this example "file1.txt" is a simple
// text file containing the words "This is a text file.".
mimeMessage.Attachments.Add(new MimeAttachmentStream("C:\\test\\file1.txt"));
                        
// Send the message.
smtp1.Server = "mail.test.com";
smtp1.Send(mimeMessage);
Visual Basic Copy Code
' Create a new MessageStream.
Dim mimeMessage as new MessageStream()

' Specify the recipient.
mimeMessage.To.Add("you@yourserver.com")

' Specify the sender.
mimeMessage.From = new MailAddress("test@dart.com")

' Add a "Subject:" header line.
mimeMessage.Subject = "MIME message"

' Add some text.
mimeMessage.Text = "This is a mime message"

' Add an attachment. For the purposes of this example "file1.txt" is a simple
' text file containing the words "This is a text file.".
mimeMessage.Attachments.Add(new MimeAttachmentStream("C:\test\file1.txt"))
                        
' Send the message.
smtp1.Server = "mail.test.com"
smtp1.Send(mimeMessage)

The code above will create a message which looks like the following (this is the encoded view):

MIME-Version: 1.0
To: <you@yourserver.com>
From: <test@dart.com>
Content-Type: multipart/mixed; boundary="--_Friday, July 19, 200212:38:18 PM891123889283"
Date: 19 Jul 2002 12:38:18 -0400
Subject: MIME message


----_Friday, July 19, 200212:38:18 PM891123889283
Content-Transfer-Encoding: Quoted-Printable
Content-Type: text/plain; charset="iso-8859-1"

This is a mime message
----_Friday, July 19, 200212:38:18 PM891123889283
Content-Transfer-Encoding: base64
Content-Type: text/plain; charset="iso-8859-1"; name="file1.txt"
Content-Disposition: attachment; filename="file1.txt"

VGhpcyBpcyBhIHRlc3QgZmlsZS4NCg==
----_Friday, July 19, 200212:38:18 PM891123889283--

 

Documentation Version 3.2
© 2010 Dart Communications. All Rights Reserved.