Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
CreateAttachmentFromString Method (String, ContentType)

Attachment.CreateAttachmentFromString Method (String, ContentType)

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

Namespace:  System.Net.Mail
Assembly:  System (in System.dll)

public static Attachment CreateAttachmentFromString(
	string content,
	ContentType contentType


Type: System.String

A String that contains the content for this attachment.

Type: System.Net.Mime.ContentType

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

Return Value

Type: System.Net.Mail.Attachment
An object of type Attachment.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft