This topic has not yet been rated Rate this topic

TransferEncoding Enumeration

Specifies the Content-Transfer-Encoding header information for an e-mail message attachment.

Namespace:  System.Net.Mime
Assembly:  System (in System.dll)
public enum TransferEncoding
Member name Description
QuotedPrintable Encodes data that consists of printable characters in the US-ASCII character set. See RFC 2406 Section 6.7.
Base64 Encodes stream-based data. See RFC 2406 Section 6.8.
SevenBit Used for data that is not encoded. The data is in 7-bit US-ASCII characters with a total line length of no longer than 1000 characters. See RFC2406 Section 2.7.
Unknown Indicates that the transfer encoding is unknown.

The values in the TransferEncoding enumeration are used with the AttachmentBase.TransferEncoding property.

The Content-Transfer-Encoding header specifies the encoding of the associated message body so that it meets SMTP requirements. SMTP requires data for transport to be in 7-bit US-ASCII characters with lines no longer than 1000 characters.

Content-Transfer-Encoding values are described in detail in RFC 2045 Section 6, available at http://www.ietf.org.

The following code example displays TransferEncoding used by an attachment.


		public static void DisplayStreamAttachment(Attachment a)
		{
			Stream s = a.ContentStream;
			StreamReader reader = new StreamReader(s);
			Console.WriteLine("Content: {0}", reader.ReadToEnd());
			Console.WriteLine("Content Type {0}", a.ContentType.ToString());
			Console.WriteLine("Transfer Encoding {0}", a.TransferEncoding);
			// Note that you cannot close the reader before the e-mail is sent. 
			// Closing the reader before sending the e-mail will close the 
			// ContentStream and cause an SmtpException.
			reader = null;
		}


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(2000 characters remaining)
Community Content Add
Annotations FAQ
Documentation Error
The above MSDN documentation actually erroneously references RFC 2406, which in fact documents the IP Encapsulating Security Payload (ESP). RFC 2045 refers correctly to Multipurpose Internet Mail Extensions, (MIME) Part One: Format of Internet Message Bodies. The sections referenced also reflect in RFC 2045, not RFC 2406.

Also, in regard to the above note about 8bit: RFC 2045 also states "Such data cannot be transmitted over some transfer protocols. For example, RFC 821 (SMTP) restricts mail messages to 7bit US-ASCII data with lines no longer than 1000 characters including any trailing CRLF line separator." Being that some protocols cannot support 8bit, as is common with many ancient but fast 36-bit UNIX servers, 8-bit encoding, though it would be wonderful, is not always practical. We all have to resort to the least common denominator to ensure reliable data integrity. Because email reaches it destination through a cloud, the intermediate transferring servers cannot all be guaranteed to support 8-bit data.
Content-Transfer-Encoding: 8bit
Where is the option for 8bit MIME transfer encoding?

In RFC2045 there is an option for 8bit encoding.

http://en.wikipedia.org/wiki/MIME#Content-Transfer-Encoding
http://tools.ietf.org/search/rfc2045