Class Attachment
Contents
[
Hide
]Attachment class
Represents an e-mail attachment.
public class Attachment : AttachmentBase, IAttachment, IPreferredTextEncodingProvider
Constructors
Name | Description |
---|---|
Attachment(string) | Initializes a new instance of the Attachment class. |
Attachment(Stream, ContentType) | Initializes a new instance of the Attachment class. |
Attachment(Stream, string) | Initializes a new instance of the Attachment class. |
Attachment(string, ContentType) | Initializes a new instance of the Attachment class. |
Attachment(string, string) | Initializes a new instance of the Attachment class. |
Attachment(Stream, string, string) | Initializes a new instance of the Attachment class. |
Properties
Name | Description |
---|---|
ContentDisposition { get; } | Gets Content-Disposition header |
ContentId { get; set; } | Gets or sets the content id. |
ContentStream { get; set; } | Gets or sets the content stream. |
ContentType { get; set; } | Gets or sets the type of the content. |
virtual Headers { get; } | Gets headers collection of attachment. |
IsEmbeddedMessage { get; } | Gets a value indicating whether the attachment is an embedded message. |
IsTnef { get; } | Gets a value indicating whether the attachment is TNEF formatted message. |
IsUri { get; } | Gets a value indicating whether attachment is URI-attachment. |
Name { get; set; } | Gets or sets an attachment name |
NameEncoding { get; set; } | Gets or sets an encoding of attachment name |
PreferredTextEncoding { get; set; } | Gets or sets a preferred text encoding |
TransferEncoding { get; set; } | Gets or sets the transfer encoding. |
Methods
Name | Description |
---|---|
static CreateAttachmentFromString(string, ContentType) | Creates the attachment from string. |
static CreateAttachmentFromString(string, string) | Creates the attachment from string. |
static CreateAttachmentFromString(string, string, Encoding, string) | Creates the attachment from string. |
Dispose() | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. |
virtual Save(Stream) | Saves the specified stream. |
virtual Save(string) | Saves the specified file name. |
Examples
The following example shows how to add and remove an Attachment from MailMessage.
[C#]
// Create an instance of MailMessage class
var eml = new MailMessage {From = "sender@sender.com", To = "receiver@gmail.com"};
// Load an attachment
var attachment = new Attachment("1.txt");
eml.Attachments.Add(attachment);
// Remove attachment from your MailMessage
eml.Attachments.Remove(attachment);
[Visual Basic]
' Create an instance of MailMessage class
Dim eml = New MailMessage With {
.From = "sender@sender.com",
.[To] = "receiver@gmail.com"
}
' Load an attachment
Dim attachment = New Attachment("1.txt")
eml.Attachments.Add(attachment)
' Remove attachment from your MailMessage
eml.Attachments.Remove(attachment)
See Also
- class AttachmentBase
- interface IAttachment
- interface IPreferredTextEncodingProvider
- namespace Aspose.Email
- assembly Aspose.Email