MailMessageSaveMessage Method (Stream)
Saves a message into the specified stream.

Namespace: MailBee.Mime
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax
public bool SaveMessage(
	Stream stream
)

Parameters

stream
Type: System.IOStream
The stream where the message should be saved.

Return Value

Type: Boolean
true if the message was successfully saved; otherwise, false.
Exceptions
ExceptionCondition
MailBeeInvalidArgumentExceptionstream is a null reference (Nothing in Visual Basic).
MailBeeStreamExceptionThe given stream does not support writing or stream I/O error occurred, and ThrowExceptions is true.
Remarks

The stream should already be opened for reading before this method can be called.

The developer can use LoadMessage(Stream) method to load the previously saved message.

If you need to produce a stream in .MSG format (which can then be opened in MS Outlook), use methods of MsgConvert class.

Examples
This sample loads the message from .EML file and saves it into the stream.
// 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).
MailMessage msg = new MailMessage();
msg.LoadMessage(@"C:\Docs\TestMail.eml");
using (FileStream fs = new FileStream(@"C:\Temp\msg.eml", FileMode.CreateNew))
{
    msg.SaveMessage(fs);
}
See Also