aspNetEmail

EmailMessage.DeSerialize Method (String, IFormatter)

Deserializes an EmailMessage object from a file.

public static EmailMessage DeSerialize(
   string path,
   IFormatter formatter
);

Parameters

path
Path to the file.
formatter
IFormatter object to use for Deserialization.

Return Value

Example

[C#]
            EmailMessage msg = new EmailMessage( "mail.myCompany.com");
            msg.FromAddress = "me@myCompany.com";
            msg.To = "You@YourCompany.com";
            msg.Subject = "test email";
            msg.Body = "enter your body contents here...";
            
            string path = "c:\\temp\\email.bin";
            
            //serialize the message to disk with a BinaryFormatter
            BinaryFormatter bf = new BinaryFormatter();
            msg.Serialize( path, bf);
            
            //deserialize at a later date and send
            BinaryFormatter bf2 = new BinaryFormatter();
            EmailMessage msg2 = EmailMessage.DeSerialize( path, bf2 );
            msg.Send();
            
[VB.NET]
            Dim msg As New EmailMessage("mail.myCompany.com")
            msg.FromAddress = "me@myCompany.com"
            msg.To = "You@YourCompany.com"
            msg.Subject = "test email"
            msg.Body = "enter your body contents here..."
            
            Dim path As String = "c:\temp\email.bin"
            
            'serialize the message to disk with a BinaryFormatter
            Dim bf As New BinaryFormatter()
            msg.Serialize(path, bf)
            
            'deserialize at a later date and send
            Dim bf2 As New BinaryFormatter()
            Dim msg2 As EmailMessage = EmailMessage.DeSerialize(path, bf2)
            msg.Send()
            
            

See Also

EmailMessage Class | aspNetEmail Namespace | EmailMessage.DeSerialize Overload List