MailMessageDeserialize Method (XmlTextReader) |
Loads a message from XML stream using the specified
XmlTextReader object.
Namespace: MailBee.MimeAssembly: MailBee.NET.45 (in MailBee.NET.45.dll) Version: 10.0.45.502
Syntaxpublic bool Deserialize(
XmlTextReader xmlReader
)
Public Function Deserialize (
xmlReader As XmlTextReader
) As Boolean
Parameters
- xmlReader
- Type: System.XmlXmlTextReader
An XmlTextReader object.
Return Value
Type:
Booleantrue if the message was successfully loaded from the XML stream; otherwise,
false.
Exceptions
Remarks
ExamplesThis 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"));
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"))
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