TransferEncoding 枚举

定义

指定电子邮件附件的 Content-Transfer-Encoding 标头信息。

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

字段

Base64 1

将基于流的数据编码。 请参见 RFC 2406 第 6.8 节。

EightBit 3

数据为可表示国际字符的 8 位字符,总行长不超过 1000 个字符。 更多关于 8 位 MIME 传送扩展的信息,请参见 IETF RFC 6152。

QuotedPrintable 0

将由 US-ASCII 字符集中可打印的字符组成的数据编码。 请参阅 RFC 2406 第 6.7 节。

SevenBit 2

用于不编码的数据。 数据为 7 位 US-ASCII 字符,总行长不超过 1000 个字符。 请参见 RFC2406 第 2.7 节。

Unknown -1

表示传输编码未知。

示例

下面的代码示例显示 TransferEncoding 附件使用的代码示例。

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

Content-Transfer-Encoding 标头指定关联的消息正文的编码,使其满足 SMTP 要求。 SMTP 要求传输数据以 7 位 US-ASCII 字符表示,行不超过 1000 个字符。

内容传输编码值在 RFC 2045 第 6 节中详细介绍,可在其中 https://www.ietf.org获取。

适用于