MailMessageDeserialize Method (XmlTextReader)
Loads a message from XML stream using the specified XmlTextReader object.

Namespace: MailBee.Mime
Assembly: MailBee.NET.45 (in MailBee.NET.45.dll) Version: 10.0.45.502
Syntax
public bool Deserialize(
	XmlTextReader xmlReader
)

Parameters

xmlReader
Type: System.XmlXmlTextReader
An XmlTextReader object.

Return Value

Type: Boolean
true if the message was successfully loaded from the XML stream; otherwise, false.
Exceptions
ExceptionCondition
MailBeeInvalidArgumentExceptionxmlReader is a null reference (Nothing in Visual Basic).
MailBeeIOExceptionAn I/O error occurred and the ThrowExceptions property is true.
Remarks
This method can loada a message which was previously serialized using Serialize(XmlTextWriter) method.
Examples
This sample loads the message from .EML file, saves it into .XML file, and then loads this message back from the .XML file.
using System;
using System.Xml;
using System.IO;
using MailBee;
using MailBee.Mime;

class Sample
{
    static void Main(string[] args)
    {
        // Load the message from file.
        MailMessage msg = new MailMessage();
        msg.LoadMessage(@"C:\Docs\msg.eml");

        // Display the subject of the message and
        // save this message to .XML file.
        Console.WriteLine(msg.Subject);
        msg.Serialize(@"C:\Temp\msg.xml");

        XmlTextReader reader = null;
        try
        {
            // Open .XML file for reading.
            reader = new XmlTextReader(File.OpenRead(@"C:\Temp\msg.xml"));

            // Load the message from .XML file.
            MailMessage newMsg = new MailMessage();
            newMsg.Deserialize(reader);

            // Display the subject of the message.
            Console.WriteLine(newMsg.Subject);
        }
        finally
        {
            if (reader != null) reader.Close();
        }
    }
}
See Also