Attachment Class
Provides properties and methods for constructing or examining a single attachment to the mail message.
Inheritance Hierarchy
SystemObject
  MailBee.MimeAttachment

Namespace: MailBee.Mime
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.4 build 677 for .NET 4.5
Syntax
public class Attachment

The Attachment type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleAttachment
Creates a new instance of Attachment object from the specified MimePart object.
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodCode exampleGetAttachmentsFromTnef
Extracts all the files from TNEF container and returns them as AttachmentCollection.
Public methodCode exampleGetAttachmentsFromTnef(TnefExtractionOptions)
Extracts items of the specified kinds from TNEF container and returns them as AttachmentCollection.
Public methodCode exampleGetData
Gets the actual content of the attachment as a byte array.
Public methodCode exampleGetData(Int32, Int32)
Gets the specified portion of the actual content of the attachment as a byte array.
Public methodCode exampleGetEncapsulatedMessage
Gets the encapsulated e-mail message as a MailMessage object.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodCode exampleSave
Saves the content of the attachment into the specified file.
Public methodSaveAsync
async/await version of Save(String, Boolean).
Public methodCode exampleSaveToFolder
Saves the content of the attachment into a file in the specified folder.
Public methodSaveToFolderAsync
async/await version of SaveToFolder(String, Boolean).
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Properties
  NameDescription
Public propertyCode exampleAsMimePart
Gets the attachment as MimePart object.
Public propertyCode exampleContentID
Gets the Content-ID value of the attachment.
Public propertyCode exampleContentLocation
Gets the content location of the attachment.
Public propertyCode exampleContentType
Gets the content type of the attachment.
Public propertyCode exampleDescription
Gets the description of the attachment.
Public propertyCode exampleFilename
Gets the filename of the attachment.
Public propertyCode exampleFilenameOriginal
Gets the original filename of the attachment.
Public propertyCode exampleHeaders
Gets the collection of the attachment headers.
Public propertyCode exampleIsFile
Indicates if the attachment is a file.
Public propertyCode exampleIsInline
Indicates if the attachment is inline.
Public propertyCode exampleIsMessageInside
Indicates if the attachment contains a mail message.
Public propertyCode exampleIsTnef
Indicates if the attachment is MS-TNEF (winmail.dat) container which can have other attachments inside.
Public propertyCode exampleIsVCard
Indicates if the attachment is a vCard profile.
Public propertyCode exampleIsZip
Indicates if the attachment is a zip archive.
Public propertyCode exampleLastResult
Gets a numeric code of the last error.
Public propertyCode exampleName
Gets the friendly name of the attachment.
Public propertyCode exampleRawHeader
Gets a string containing the header section of the attachment in the original form.
Public propertyCode exampleSavedAs
Gets the full path to the attachment which was saved to disk.
Public propertyCode exampleSize
Gets the length of the binary content of the attachment.
Public propertyCode exampleThrowExceptions
Gets or sets whether the object will throw exceptions on errors.
Top
Remarks

All the attachments to the message (including embedded pictures) are stored in Attachments collection of the MailMessage object.

You can also create MDN attachments (deliver-status reports). See Add(String, String, HeaderCollection, MailTransferEncoding) for details.

Examples
This sample loads the message from .EML file and displays filenames of all attachments to this message.
// To use the code below, import MailBee namespaces at the top of your code.
using MailBee;
using MailBee.Mime;

// The actual code (put it into a method of your class)

// Load the message from file.
MailMessage msg = new MailMessage();
msg.LoadMessage(@"C:\Docs\TestMail.eml");

// For every attachment...
foreach (Attachment attach in msg.Attachments)
{
    // ...show the filename of the attachment.
    Console.WriteLine("Attachment name is " + attach.Filename);
}
See Also