MailMessageDeserialize Method (XmlReader) |
Loads a message from XML stream using the specified
XmlReader object.
Namespace: MailBee.MimeAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public bool Deserialize(
XmlReader xmlReader
)
Public Function Deserialize (
xmlReader As XmlReader
) As Boolean
Parameters
- xmlReader
- Type: System.XmlXmlReader
An XmlReader object.
Return Value
Type:
Booleantrue if the message was successfully loaded from the XML stream; otherwise,
false.
Exceptions 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)
{
MailMessage msg = new MailMessage();
msg.LoadMessage(@"C:\Docs\msg.eml");
Console.WriteLine(msg.Subject);
msg.Serialize(@"C:\Temp\msg.xml");
XmlTextReader reader = null;
try
{
reader = new XmlTextReader(File.OpenRead(@"C:\Temp\msg.xml"));
reader.WhitespaceHandling = WhitespaceHandling.None;
MailMessage newMsg = new MailMessage();
newMsg.Deserialize(reader);
Console.WriteLine(newMsg.Subject);
}
finally
{
if (reader != null) reader.Close();
}
}
}
Imports System
Imports System.IO
Imports System.Xml
Imports MailBee
Imports MailBee.Mime
Module Sample
Sub Main(ByVal args As String())
Dim msg As New MailMessage
msg.LoadMessage("C:\Docs\msg.eml")
Console.WriteLine(msg.Subject)
msg.Serialize("C:\Temp\msg.xml")
Dim reader As XmlTextReader = Nothing
Try
reader = New XmlTextReader(File.OpenRead("C:\Temp\msg.xml"))
reader.WhitespaceHandling = WhitespaceHandling.None
Dim newMsg As New MailMessage
newMsg.Deserialize(reader)
Console.WriteLine(newMsg.Subject)
Finally
If Not reader Is Nothing Then reader.Close()
End Try
End Sub
End Module
See Also