MailMessageSerialize Method (XmlWriter)
Saves the message into XML stream using the specified XmlWriter object.

Namespace: MailBee.Mime
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax
public bool Serialize(
	XmlWriter xmlWriter
)

Parameters

xmlWriter
Type: System.XmlXmlWriter
An XmlWriter object.

Return Value

Type: Boolean
true if the message was successfully saved to .XML file; otherwise, false.
Exceptions
ExceptionCondition
MailBeeInvalidArgumentExceptionxmlWriter is a null reference (Nothing in Visual Basic).
MailBeeIOExceptionAn I/O error occurred and ThrowExceptions is true.
Remarks
The saved message can be loaded back from .XML file using the Deserialize(XmlReader) method.
Examples
This sample loads the message from .EML file and saves this message to .XML file.
// 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();
}
See Also