Deserializes an EmailMessage object from a stream.
[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
FileStream fs = File.OpenWrite( path );
BinaryFormatter bf = new BinaryFormatter();
msg.Serialize( fs, bf);
fs.Flush();
fs.Close();
//deserialize at a later date and send
BinaryFormatter bf2 = new BinaryFormatter();
FileStream fs2 = File.OpenRead( path );
EmailMessage msg2 = EmailMessage.DeSerialize( path, bf2 );
fs.Close();
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 fs As FileStream = File.OpenWrite(path)
Dim bf As New BinaryFormatter()
msg.Serialize(fs, bf)
fs.Flush()
fs.Close()
'deserialize at a later date and send
Dim bf2 As New BinaryFormatter()
Dim fs2 As FileStream = File.OpenRead(path)
Dim msg2 As EmailMessage = EmailMessage.DeSerialize(path, bf2)
fs.Close()
msg.Send()
EmailMessage Class | aspNetEmail Namespace | EmailMessage.DeSerialize Overload List