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

Namespace: MailBee.Mime
Assembly: MailBee.NET.45 (in MailBee.NET.45.dll) Version: 10.0.45.502
Syntax
public bool Serialize(
	XmlTextWriter xmlWriter
)

Parameters

xmlWriter
Type: System.XmlXmlTextWriter
An XmlTextWriter 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(XmlTextReader) 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