TransferEncoding Enum
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Specifies the Content-Transfer-Encoding header information for an email message attachment.
public enum class TransferEncoding
public enum TransferEncoding
type TransferEncoding =
Public Enum TransferEncoding
- Inheritance
Name | Value | Description |
---|---|---|
Unknown | -1 | Indicates that the transfer encoding is unknown. |
QuotedPrintable | 0 | Encodes data that consists of printable characters in the US-ASCII character set. See RFC 2406 Section 6.7. |
Base64 | 1 | Encodes stream-based data. See RFC 2406 Section 6.8. |
SevenBit | 2 | 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. |
EightBit | 3 | The data is in 8-bit characters that may represent international characters with a total line length of no longer than 1000 8-bit characters. For more information about this 8-bit MIME transport extension, see IETF RFC 6152. |
The following code example displays TransferEncoding used by an attachment.
static void DisplayStreamAttachment( Attachment^ a )
{
Stream^ s = a->ContentStream;
StreamReader^ reader = gcnew StreamReader( s );
Console::WriteLine( L"Content: {0}", reader->ReadToEnd() );
Console::WriteLine( L"Content Type {0}", a->ContentType );
Console::WriteLine( L"Transfer Encoding {0}", a->TransferEncoding );
// Note that you cannot close the reader before the email is sent.
// Closing the reader before sending the email will close the
// ContentStream and cause an SmtpException.
reader = nullptr;
}
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 email is sent.
// Closing the reader before sending the email will close the
// ContentStream and cause an SmtpException.
reader = null;
}
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 https://www.ietf.org.
Product | Versions |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: