AttachmentGetData Method (Int32, Int32) |
Gets the specified portion of the actual content of the attachment as a byte array.
Namespace: MailBee.MimeAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public byte[] GetData(
int offset,
int size
)
Public Function GetData (
offset As Integer,
size As Integer
) As Byte()
Parameters
- offset
- Type: SystemInt32
The number of bytes which should be skipped before starting reading the attachment content. - size
- Type: SystemInt32
The number of bytes which should be read. If -1, the content will be read from the offset position till the end of the data.
Return Value
Type:
ByteThe specified portion of the actual content of the attachment as a byte array.
Examples This sample loads the message from .EML file and saves the first attachment to disk using
BinaryWriter object.
using System.IO;
using MailBee;
using MailBee.Mime;
MailMessage msg = new MailMessage();
msg.LoadMessage(@"C:\Docs\TestMail.eml");
if (msg.Attachments.Count > 0)
{
using (BinaryWriter bw = new BinaryWriter(File.OpenWrite(@"C:\Temp\" + msg.Attachments[0].Filename)))
{
bw.Write(msg.Attachments[0].GetData(0, -1));
}
}
Imports System.IO
Imports MailBee
Imports MailBee.Mime
Dim msg As New MailMessage
msg.LoadMessage("C:\Docs\TestMail.eml")
If msg.Attachments.Count > 0 Then
Dim bw As BinaryWriter
Try
bw = New BinaryWriter(System.IO.File.OpenWrite("C:\Temp\" & msg.Attachments(0).Filename))
bw.Write(msg.Attachments(0).GetData(0, -1))
Finally
If Not bw Is Nothing Then
bw.Close()
End If
End Try
End If
See Also