aspNetEmail

EmailMessage.Parse Method (String)

Parses a RFC2822 formatted message sting into an EmailMessage

public static EmailMessage Parse(
   string contents
);

Parameters

contents
A string of contents formatted as a Mime/Email message that conforms to the RFC 2822 standard.

Remarks

The RFC 2822 format is the standard format found in email messages. The text is basically formatted with email headers, a blank line, and then a body.

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  );
            
            //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)
            
            'set the server	
            msg.Server = "mail.myCompany.com"
            
            'send
            msg.Send()
            
            

See Also

EmailMessage Class | aspNetEmail Namespace | EmailMessage.Parse Overload List