TransferEncoding 列舉

定義

指定電子郵件訊息附件的內容傳遞編碼標頭資訊。

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

欄位

Base64 1

對以資料流為基礎的資料進行編碼。 請參閱 RFC 2406 第 6.8 節。

EightBit 3

這種資料為代表國際字元的 8 位元字元,且行的總長度不超過 1000 個 8 位元字元。 如需這個 8 位元 MIME 傳輸擴充功能的詳細資訊,請參閱 IETF RFC 6152。

QuotedPrintable 0

對資料進行編碼,而且該資料是由 US-ASCII 字元集內的可列印字元所組成。 請參閱 RFC 2406 第 6.7 節。

SevenBit 2

用於未編碼的資料。 這種資料為 7 位元 US-ASCII 字元,且行的總長度不超過 1000 個字元。 請參閱 RFC 2406 第 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 取得。

適用於