System.Net.Mail.Attachment Class

Represents an attachment to an e-mail.

See Also: Attachment Members

Syntax

public class Attachment : AttachmentBase

Remarks

The System.Net.Mail.Attachment class is used with the System.Net.Mail.MailMessage class. All messages include a MailMessage.Body, which contains the content of the message. In addition to the body, you might want to send additional files. These are sent as attachments and are represented as System.Net.Mail.Attachment instances. To add an attachment to a mail message, add it to the MailMessage.Attachments collection.

Attachment content can be a string, System.IO.Stream, or file name. You can specify the content in an attachment by using any of the erload:System.Net.Mail.Attachment.#ctor constructors.

The MIME Content-Type header information for the attachment is represented by the AttachmentBase.ContentType property. The Content-Type header specifies the media type and subtype and any associated parameters. Use AttachmentBase.ContentType to get the instance associated with an attachment.

The MIME Content-Disposition header is represented by the Attachment.ContentDisposition property. The Content-Disposition header specifies the presentation and file time stamps for an attachment. A Content-Disposition header is sent only if the attachment is a file. Use the Attachment.ContentDisposition property to get the instance associated with an attachment.

The MIME Content-Transfer-Encoding header is represented by the AttachmentBase.TransferEncoding property.

Requirements

Namespace: System.Net.Mail
Assembly: System (in System.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0