Saves a message into the specified stream.
true if the message was successfully saved; otherwise, false.
The stream should already be opened for reading before this method can be called.
The developer can use LoadMessage method to load the previously saved message.
| Exception Type | Condition |
|---|---|
| MailBeeInvalidArgumentException | stream is a null reference (Nothing in Visual Basic). |
| MailBeeStreamException | The given stream does not support writing or stream I/O error occurred, and ThrowExceptions is true. |
This sample loads the message from .EML file and saves it into the stream.
[C#] // 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); }
[Visual Basic] ' To use the code below, import these namespaces at the top of your code. Imports System.IO Imports MailBee Imports MailBee.Mime ' The actual code (put it into a method of your class). Dim msg As New MailMessage msg.LoadMessage("C:\Docs\TestMail.eml") Dim fs As FileStream Try fs = New FileStream("C:\Temp\msg.eml", FileMode.CreateNew) msg.SaveMessage(fs) Finally If Not fs Is Nothing Then fs.Close() End If End Try
MailMessage Class | MailBee.Mime Namespace | MailMessage.SaveMessage Overload List | LoadMessage