Attachment.CreateAttachmentFromString Attachment.CreateAttachmentFromString Attachment.CreateAttachmentFromString Attachment.CreateAttachmentFromString Method

Definition

Creates an attachment from a string.

Overloads

CreateAttachmentFromString(String, ContentType) CreateAttachmentFromString(String, ContentType) CreateAttachmentFromString(String, ContentType)

Creates a mail attachment using the content from the specified string, and the specified ContentType.

CreateAttachmentFromString(String, String) CreateAttachmentFromString(String, String) CreateAttachmentFromString(String, String) CreateAttachmentFromString(String, String)

Creates a mail attachment using the content from the specified string, and the specified MIME content type name.

CreateAttachmentFromString(String, String, Encoding, String) CreateAttachmentFromString(String, String, Encoding, String) CreateAttachmentFromString(String, String, Encoding, String) CreateAttachmentFromString(String, String, Encoding, String)

Creates a mail attachment using the content from the specified string, the specified MIME content type name, character encoding, and MIME header information for the attachment.

CreateAttachmentFromString(String, ContentType) CreateAttachmentFromString(String, ContentType) CreateAttachmentFromString(String, ContentType)

Creates a mail attachment using the content from the specified string, and the specified 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

Parameters

content
String String String String

A String that contains the content for this attachment.

contentType
ContentType ContentType ContentType ContentType

A ContentType object that represents the Multipurpose Internet Mail Exchange (MIME) protocol Content-Type header to be used.

Returns

CreateAttachmentFromString(String, String) CreateAttachmentFromString(String, String) CreateAttachmentFromString(String, String) CreateAttachmentFromString(String, String)

Creates a mail attachment using the content from the specified string, and the specified MIME content type name.

public:
 static System::Net::Mail::Attachment ^ CreateAttachmentFromString(System::String ^ content, System::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

Parameters

content
String String String String

A String that contains the content for this attachment.

name
String String String String

The MIME content type name value in the content type associated with this attachment.

Returns

Remarks

If the content is in ASCII format then the character encoding is set to ASCII. For all other formats, the character encoding is set to utf-8. The default media type is plain text.

If the content is not in ASCII format and the encoding is null, utf-8 encoding is used.

CreateAttachmentFromString(String, String, Encoding, String) CreateAttachmentFromString(String, String, Encoding, String) CreateAttachmentFromString(String, String, Encoding, String) CreateAttachmentFromString(String, String, Encoding, String)

Creates a mail attachment using the content from the specified string, the specified MIME content type name, character encoding, and MIME header information for the attachment.

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);
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

Parameters

content
String String String String

A String that contains the content for this attachment.

name
String String String String

The MIME content type name value in the content type associated with this attachment.

contentEncoding
Encoding Encoding Encoding Encoding

An Encoding. This value can be null.

mediaType
String String String String

A String that contains the MIME Content-Header information for this attachment. This value can be null.

Returns

Applies to