MailMessageGetMessageRawData Method |
Gets the source of the message 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[] GetMessageRawData()
Public Function GetMessageRawData As Byte()
Return Value
Type:
Byte
A byte array representing the MIME source of the message.
Remarks
To get only a header section of the message, use
RawHeader property.
To save the message to disk or into a stream, use
SaveMessage(String) method.
Examples This sample saves the MIME source of the message into .EML file for demonstration purposes only.
Real-world applications should use
SaveMessage(String) method for this.
using System.IO;
using MailBee;
using MailBee.Pop3Mail;
using MailBee.Mime;
class Sample
{
static void Main(string[] args)
{
MailMessage msg = Pop3.QuickDownloadMessage("mail.company.com", "jdoe", "password", 1);
using (BinaryWriter bw = new BinaryWriter(File.Open(@"C:\Temp\msg.eml",
FileMode.Create)))
{
bw.Write(msg.GetMessageRawData());
}
}
}
Imports System.IO
Imports MailBee
Imports MailBee.Pop3Mail
Imports MailBee.Mime
Module Sample
Sub Main(ByVal args As String())
Dim msg As MailMessage = Pop3.QuickDownloadMessage("mail.company.com", "jdoe", "password", 1)
Dim bw As BinaryWriter
Try
bw = New BinaryWriter(File.Open("C:\Temp\msg.eml", FileMode.Create))
bw.Write(msg.GetMessageRawData())
Finally
If Not bw Is Nothing Then
bw.Close()
End If
End Try
End Sub
End Module
See Also