Share via


Attachment.CreateAttachmentFromString 方法

定义

用字符串创建附件。

重载

CreateAttachmentFromString(String, ContentType)

使用指定字符串中的内容和指定的 ContentType 创建邮件附件。

CreateAttachmentFromString(String, String)

使用指定字符串中的内容和指定的 MIME 内容类型名创建邮件附件。

CreateAttachmentFromString(String, String, Encoding, String)

使用指定字符串中的内容、指定的 MIME 内容类型名、字符编码和附件的 MIME 标头信息创建邮件附件。

CreateAttachmentFromString(String, ContentType)

Source:
Attachment.cs
Source:
Attachment.cs
Source:
Attachment.cs

使用指定字符串中的内容和指定的 ContentType 创建邮件附件。

public:
 static System::Net::Mail::Attachment ^ CreateAttachmentFromString(System::String ^ content, System::Net::Mime::ContentType ^ contentType);
public static System.Net.Mail.Attachment CreateAttachmentFromString (string content, System.Net.Mime.ContentType contentType);
static member CreateAttachmentFromString : string * System.Net.Mime.ContentType -> System.Net.Mail.Attachment
Public Shared Function CreateAttachmentFromString (content As String, contentType As ContentType) As Attachment

参数

content
String

一个包含附件内容的 String

contentType
ContentType

ContentType 对象,表示使用多用途 Internet 邮件交换 (MIME) 协议 Content-Type 标头。

返回

一个 Attachment 类型的对象。

适用于

CreateAttachmentFromString(String, String)

Source:
Attachment.cs
Source:
Attachment.cs
Source:
Attachment.cs

使用指定字符串中的内容和指定的 MIME 内容类型名创建邮件附件。

public:
 static System::Net::Mail::Attachment ^ CreateAttachmentFromString(System::String ^ content, System::String ^ name);
public static System.Net.Mail.Attachment CreateAttachmentFromString (string content, string? name);
public static System.Net.Mail.Attachment CreateAttachmentFromString (string content, string name);
static member CreateAttachmentFromString : string * string -> System.Net.Mail.Attachment
Public Shared Function CreateAttachmentFromString (content As String, name As String) As Attachment

参数

content
String

一个包含附件内容的 String

name
String

与此附件关联的内容类型中的 MIME 内容类型名称值。

返回

一个 Attachment 类型的对象。

注解

如果内容采用 ASCII 格式,则字符编码设置为 ASCII。 对于所有其他格式,字符编码设置为 utf-8。 默认媒体类型为纯文本。

如果内容不是 ASCII 格式且编码为 null,则使用 utf-8 编码。

适用于

CreateAttachmentFromString(String, String, Encoding, String)

Source:
Attachment.cs
Source:
Attachment.cs
Source:
Attachment.cs

使用指定字符串中的内容、指定的 MIME 内容类型名、字符编码和附件的 MIME 标头信息创建邮件附件。

public:
 static System::Net::Mail::Attachment ^ CreateAttachmentFromString(System::String ^ content, System::String ^ name, System::Text::Encoding ^ contentEncoding, System::String ^ mediaType);
public static System.Net.Mail.Attachment CreateAttachmentFromString (string content, string? name, System.Text.Encoding? contentEncoding, string? mediaType);
public static System.Net.Mail.Attachment CreateAttachmentFromString (string content, string name, System.Text.Encoding contentEncoding, string mediaType);
static member CreateAttachmentFromString : string * string * System.Text.Encoding * string -> System.Net.Mail.Attachment
Public Shared Function CreateAttachmentFromString (content As String, name As String, contentEncoding As Encoding, mediaType As String) As Attachment

参数

content
String

一个包含附件内容的 String

name
String

与此附件关联的内容类型中的 MIME 内容类型名称值。

contentEncoding
Encoding

Encoding。 此值可为 null

mediaType
String

String 包含此附件的 MIME 内容标头信息。 此值可为 null

返回

一个 Attachment 类型的对象。

适用于