Attachment.CreateAttachmentFromString Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Creates an attachment from a string.
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. |
- 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
- 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
.NET 9 and other versions
Product | Versions |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
- 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
- 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
.NET 9 and other versions
Product | Versions |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
- 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
- name
- String
The MIME content type name value in the content type associated with this attachment.
- 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
.NET 9 and other versions
Product | Versions |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: