Saves the message into XML stream using the specified XmlTextWriter object.
true if the message was successfully saved to .XML file; otherwise, false.
The saved message can be loaded back from .XML file using the Deserialize method.
| Exception Type | Condition |
|---|---|
| MailBeeInvalidArgumentException | xmlWriter is a null reference (Nothing in Visual Basic). |
| MailBeeIOException | An I/O error occurred and ThrowExceptions is true. |
This sample loads the message from .EML file and saves this message to .XML file.
[C#] // To use the code below, import MailBee namespaces at the top of your code. using System.Xml; using System.Text; 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"); XmlTextWriter xtw = null; try { xtw = new XmlTextWriter(@"C:\Temp\msg.xml", Encoding.UTF8); msg.Serialize(xtw); } finally { if (xtw != null) xtw.Close(); }
[Visual Basic] ' To use the code below, import these namespaces at the top of your code. Imports System.Xml Imports System.Text 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 xtw As XmlTextWriter = Nothing Try xtw = New XmlTextWriter("C:\Temp\msg.xml", Encoding.UTF8) msg.Serialize(xtw) Finally If Not xtw Is Nothing Then xtw.Close() End If End Try
MailMessage Class | MailBee.Mime Namespace | MailMessage.Serialize Overload List