aspNetEmail

EmailMessage.Parse Method (String, Encoding, Boolean)

Parses an EmailMessage from a RFC2822 formatted string.

public static EmailMessage Parse(
   string contents,
   Encoding encoding,
   bool throwException
);

Parameters

contents
String of the RFC2822 message
encoding
Encoding used to read the string.
throwException
Throw any exceptions while parsing the message.

Return Value

Example

[C#]
            //load an email message from the filesystem
            string path = "c:\\temp\\sample.eml";
            StreamReader sr = new StreamReader( path );
            string contents = sr.ReadToEnd();
            sr.Close();
            
            EmailMessage msg = EmailMessage.Parse( contents, Encoding.UTF8, false  );
            
            //set the server	
            msg.Server = "mail.myCompany.com";
            
            //send
            msg.Send();
            
[VB.NET]
             'load an email message from the filesystem
            Dim path As String = "c:\temp\sample.eml"
            Dim sr As New StreamReader(path)
            Dim contents As String = sr.ReadToEnd()
            sr.Close()
            
            Dim msg As EmailMessage = EmailMessage.Parse(contents, Encoding.UTF8, False)
            
            'set the server	
            msg.Server = "mail.myCompany.com"
            
            'send
            msg.Send()
            
            

See Also

EmailMessage Class | aspNetEmail Namespace | EmailMessage.Parse Overload List