MailBee.NET Objects 6.0

MailMessage.LoadMessage Method (String)

Loads the message from the specified file.

public bool LoadMessage(
   string filename
);

Parameters

filename
The path to the file containing the message in MIME format. The common extension of MIME files is .EML.

Return Value

true if the message was successfully loaded; otherwise, false.

Remarks

To save a message into a file, use SaveMessage method.

Exceptions

Exception Type Condition
MailBeeInvalidArgumentException filename is a null reference (Nothing in Visual Basic) or an empty string.
MailBeeIOException An I/O error occurred and ThrowExceptions is true.

Example

This sample loads the message from .EML file and displays the subject of the message.

[C#]
// 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");

Console.WriteLine(msg.Subject);
[Visual Basic]
' To use the code below, import MailBee namespaces at the top of your code.
Imports MailBee
Imports MailBee.Mime

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

' Load the message from file.
Dim msg As New MailMessage
msg.LoadMessage("C:\Docs\TestMail.eml")

Console.WriteLine(msg.Subject)

See Also

MailMessage Class | MailBee.Mime Namespace | MailMessage.LoadMessage Overload List | SaveMessage