Loads and sets various EmailMessage properties from the application configuration file.
This constructor is useful for creating an email message object with preset properties and methods. For more information be sure to check out LoadFromConfig
This ctor is useful for quickly sending email such as adminstartive emails, error alerts, order confirmation, ecommerce reciepts, and many other types of emails.
[C#]
This example loads an email message from the web.config and immediately sends it.
<%@ Page language="c#" %>
<%@ Import Namespace="aspNetEmail" %>
<script runat=server>
private void Page_Load(object sender, System.EventArgs e)
{
EmailMessage msg = new EmailMessage( true, true );
Response.Write(" email sent!" );
}
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title></title>
</head>
<body >
<form id="emailmessage1" method="post" runat="server">
</form>
</body>
</html>
Where the web.config has the following values
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="EmailMessage.To" value="dave@mycompany.com"></add>
<add key="EmailMessage.FromAddress" value="dave@mycompany.com"></add>
<add key="EmailMessage.Server" value="mail.mycompany.com"></add>
<add key="EmailMessage.Subject" value="this email sent from the web.config"></add>
<add key="EmailMessage.BodyFormat" value="html"></add>
<add key="EmailMessage.Body" value="<b>this is my bold email sent from the web.config</b>" />
</appSettings>
<system.web>
</system.web>
</configuration>
[Visual Basic]
This example loads an email message from the web.config and immediately sends it.
<%@ Page language="VB" %>
<%@ Import Namespace="aspNetEmail" %>
<script runat=server>
Sub Page_Load(sender as Object, e as System.EventArgs )
Dim msg as EmailMessage = new EmailMessage( true, true )
Response.Write(" email sent!" )
End Sub
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title></title>
</head>
<body >
<form id="emailmessage1" method="post" runat="server">
</form>
</body>
</html>
Where the web.config has the following values
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="EmailMessage.To" value="dave@mycompany.com"></add>
<add key="EmailMessage.FromAddress" value="dave@mycompany.com"></add>
<add key="EmailMessage.Server" value="mail.mycompany.com"></add>
<add key="EmailMessage.Subject" value="this email sent from the web.config"></add>
<add key="EmailMessage.BodyFormat" value="html"></add>
<add key="EmailMessage.Body" value="<b>this is my bold email sent from the web.config</b>" />
</appSettings>
<system.web>
</system.web>
</configuration>
EmailMessage Class | aspNetEmail Namespace | EmailMessage Constructor Overload List | LoadFromConfig