AttachmentGetData Method
Gets the actual content of the attachment as a byte array.

Namespace: MailBee.Mime
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.4 build 677 for .NET 4.5
Syntax
public byte[] GetData()

Return Value

Type: Byte
A byte array containing the actual content of the attachment.
Remarks
To get a certain portion of the attachment's content (rather than the entire data), use GetData(Int32, Int32) overload.
Examples
This sample loads the message from .EML file and saves the first attachment to disk using GetData method and streams.
Note Note
In real-world apps, it's easier to use Save(String, Boolean) or SaveToFolder(String, Boolean) methods to save an attachment to disk.
// To use the code below, import these namespaces at the top of your code.
using System.IO;
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");

// When there is any attachment...
if (msg.Attachments.Count > 0)
{
    // ...then open a file for writing...
    using (BinaryWriter bw = new BinaryWriter(File.OpenWrite(@"C:\Temp\" + msg.Attachments[0].Filename)))
    {
        // ...and write the attachment's content to the file.
        bw.Write(msg.Attachments[0].GetData());
    }
}
See Also