TransferEncoding 枚举

定义

指定电子邮件附件的 Content-Transfer-Encoding 标头信息。Specifies the Content-Transfer-Encoding header information for an email message attachment.

public enum class TransferEncoding
public enum TransferEncoding
type TransferEncoding = 
Public Enum TransferEncoding
继承
TransferEncoding

字段

Base64 1

将基于流的数据编码。Encodes stream-based data. 请参见 RFC 2406 第 6.8 节。See RFC 2406 Section 6.8.

EightBit 3

数据为可表示国际字符的 8 位字符,总行长不超过 1000 个字符。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. 更多关于 8 位 MIME 传送扩展的信息,请参见 IETF RFC 6152。For more information about this 8-bit MIME transport extension, see IETF RFC 6152.

QuotedPrintable 0

将由 US-ASCII 字符集中可打印的字符组成的数据编码。Encodes data that consists of printable characters in the US-ASCII character set. 请参阅 RFC 2406 第 6.7 节。See RFC 2406 Section 6.7.

SevenBit 2

用于不编码的数据。Used for data that is not encoded. 数据为 7 位 US-ASCII 字符,总行长不超过 1000 个字符。The data is in 7-bit US-ASCII characters with a total line length of no longer than 1000 characters. 请参见 RFC2406 第 2.7 节。See RFC2406 Section 2.7.

Unknown -1

表示传输编码未知。Indicates that the transfer encoding is unknown.

示例

下面的代码示例显示TransferEncoding附件使用。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;
}

注解

TransferEncoding枚举中的值AttachmentBase.TransferEncoding与属性一起使用。The values in the TransferEncoding enumeration are used with the AttachmentBase.TransferEncoding property.

内容传输编码标头指定关联消息正文的编码, 以便满足 SMTP 要求。The Content-Transfer-Encoding header specifies the encoding of the associated message body so that it meets SMTP requirements. SMTP 需要传输的数据位于7位的 US-ASCII 字符中, 行的长度不能超过1000个字符。SMTP requires data for transport to be in 7-bit US-ASCII characters with lines no longer than 1000 characters.

内容传输编码值在 RFC 2045 第6部分中有详细说明, 请https://www.ietf.org参阅。Content-Transfer-Encoding values are described in detail in RFC 2045 Section 6, available at https://www.ietf.org.

适用于