Attachment.CreateAttachmentFromString Method

Definition

Creates an attachment from a string.

Overloads

CreateAttachmentFromString(String, ContentType)

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

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)

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)

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

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
Public Shared Function CreateAttachmentFromString (content As String, contentType As ContentType) As Attachment

Parameters

content
String

A String that contains the content for this attachment.

contentType
ContentType

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

Returns

An object of type Attachment.

Applies to

CreateAttachmentFromString(String, String)

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

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

A String that contains the content for this attachment.

name
String

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

Returns

An object of type Attachment.

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.

Applies to

CreateAttachmentFromString(String, String, Encoding, String)

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

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

A String that contains the content for this attachment.

name
String

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

contentEncoding
Encoding

An Encoding. This value can be null.

mediaType
String

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

Returns

An object of type Attachment.

Applies to