aspNetEmail

EmailMessage.GetBodyFromFile Method 

This method will populate the body of the email with the contents from a text file. The file can either be pure text, or may contain HTML. If the file is a HTML file, you will want to set the BodyFormat property to 1 for HTML formatted email.

public bool GetBodyFromFile(
   string filePath
);

Parameters

filePath
The path to the file, that will populate the body. For example c:\EmailFiles\MyBodyFile.txt

Return Value

Example

[C#]
		EmailMessage msg = new EmailMessage("Mail1.MyCompany.com");
		msg.FromAddress = "me@MyCompany.com";
		msg.AddTo( "you@YourCompany.com", "Billy Bob" );
		msg.Subject = "Daily Newsletter";
		msg.GetBodyFromFile(@"C:\temp\DailyNewsletter.txt");
		if ( msg.Send() )
		{
			Console.WriteLine( "Message Sent!");
		}
		else
		{
			Console.WriteLine( msg.LastException().Message );
		}
		
[Visual Basic]
		Dim msg As New EmailMessage("Mail1.MyCompany.com")
		msg.FromAddress = "me@MyCompany.com"
		msg.AddTo("you@YourCompany.com", "Billy Bob")
		msg.Subject = "Daily Newsletter"
		msg.GetBodyFromFile("C:\temp\DailyNewsletter.txt")
		If (msg.Send()) Then
		    Console.WriteLine("Message Sent!")
		Else
		    Console.WriteLine(msg.LastException().Message)
		End If
		

See Also

EmailMessage Class | aspNetEmail Namespace