Mail.Load Method


Loads a RFC822 message ( *.eml) file or binary email content to current Mail instance.

[Visual Basic]
Public Sub Load( _
    fileName As String, _
    lateLoadBody As Boolean 
)

Public Sub Load( _
    content() As Byte _
)
[C#]
public void Load(
    string fileName,
    bool lateLoadBody
);

public void Load(
    byte[] content
);
[C++]
public: void Load(
    String^ fileName,
    bool lateLoadBody
);

public: void Load(
    array<unsigned char> content
);
[JScript]
public function Load( 
    fileName : String,
    lateLoadBody : Boolean
);

public function Load( 
    content : Byte[]
);

Parameters

fileName
A full file name (*.eml) of RFC822 message.
lateLoadBody
If this parameter is false, all content of the file will be loaded; If this parameter is true, this method only loads headers of the email to save memory, and will load all content automatically on demand.
content
The binary data of the email.

Example

[Visual Basic, C#, C++] The following example demonstrates how to parse from, to, cc. To get the full samples of EAGetMail, please refer to Samples section.

[Visual Basic - Parse Email From, ReplyTo, To, CC]
Imports EAGetMail

Public Sub ParseMailAddress()
    Dim oMail As New Mail("TryIt")
    oMail.Load("c:\test.eml", False)

    Dim addr As MailAddress = oMail.ReplyTo
    Console.WriteLine("Reply-To: {0} <{1}>", addr.Name, addr.Address)
    addr = oMail.From
    Console.WriteLine("From: {0} <{1}>", addr.Name, addr.Address)

    Dim addrs() As MailAddress = oMail.To
    Dim count As Integer = addrs.Length
    For i As Integer = 0 To count - 1
        addr = addrs(i)
        Console.WriteLine("To: {0} <{1}>", addr.Name, addr.Address)
    Next

    addrs = oMail.Cc
    count = addrs.Length
    For i As Integer = 0 To count - 1
        addr = addrs(i)
        Console.WriteLine("Cc: {0} <{1}>", addr.Name, addr.Address)
    Next
End Sub


[C# - Parse Email From, ReplyTo, To, CC] using System; using System.Collections; using EAGetMail; public static void ParseMailAddress() { Mail oMail = new Mail("TryIt"); oMail.Load("c:\\test.eml", false); MailAddress addr = oMail.ReplyTo; Console.WriteLine("Reply-To: {0} <{1}>", addr.Name, addr.Address); addr = oMail.From; Console.WriteLine("From: {0} <{1}>", addr.Name, addr.Address); MailAddress[] addrs = oMail.To; int count = addrs.Length; for(int i = 0; i < count; i++) { addr = addrs[i]; Console.WriteLine("To: {0} <{1}>", addr.Name, addr.Address); } addrs = oMail.Cc; count = addrs.Length; for(int i = 0; i < count; i++) { addr = addrs[i]; Console.WriteLine("Cc: {0} <{1}>", addr.Name, addr.Address); } }
[C++/CLI - Parse Email From, ReplyTo, To, CC] using namespace System; using namespace System::Collections; using namespace EAGetMail; Void ParseMailAddress() { Mail ^oMail = gcnew Mail("TryIt"); oMail->Load("c:\\test.eml", false); MailAddress ^addr = oMail->ReplyTo; Console::WriteLine("Reply-To: {0} <{1}>", addr->Name, addr->Address); addr = oMail->From; Console::WriteLine("From: {0} <{1}>", addr->Name, addr->Address); array<MailAddress^> ^addrs = oMail->To; int count = addrs->Length; for(int i = 0; i < count; i++) { addr = addrs[i]; Console::WriteLine("To: {0} <{1}>", addr->Name, addr->Address); } addrs = oMail->Cc; count = addrs->Length; for(int i = 0; i < count; i++) { addr = addrs[i]; Console::WriteLine("Cc: {0} <{1}>", addr->Name, addr->Address); } }

See Also

Mail.LoadOMSG Method
Mail.SaveAs Method

Online Tutorials

Parse Email in C# - Tutorial
Parse Email in VB.NET - Tutorial
Parse Email in C++/CLI - Tutorial