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

Namespace: MailBee.Mime
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.4 build 677 for .NET 4.5
Syntax
public bool Deserialize(
	XmlReader xmlReader
)

Parameters

xmlReader
Type: System.XmlXmlReader
An XmlReader 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(XmlWriter) method. Be sure to disable white-space handling when using this 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"));
            reader.WhitespaceHandling = WhitespaceHandling.None;

            // 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