Load Templates From Files

The following example demonstrates loading the message body from files. In this example EmailTemplate1 loads it's TextBody from a file named 'confirm.txt', and loads the HtmlBody from a file named 'confirm.htm'. EmailTemplate1 then sends a confirmation email to the address set by txtEmail. EmailTemplate2 simply sends an email to sales@example.com with the submitted information.

[ASP.NET]

<%@ Page language="c#" %>
<%@ Register NameSpace="aspNetEmail.Web.UI.WebControls" Assembly="aspNetEmail" TagPrefix="Email"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
  <HEAD>
		</title>
</HEAD>
	<body>
		<form id="WebForm1" method="post" runat="server" ENCTYPE="multipart/form-data">
				This sample form demonstrates the EmailTemplate control.
				<br>
				<br>
				
                <!-- this control is used to send a confirmation email to the email address submitted --> 
                <Email:EmailTemplate  
                Server="127.0.0.1" 
                To="##txtEmail##" 
                FromAddress="sales@example.com" 
                Subject="Confirmation Email" 
                ID="Emailtemplate1"  
                TextBodyTemplatePath="confirm.txt" 
                HtmlBodyTemplatePath="confirm.htm" 
                Runat=server> 
                </Email:EmailTemplate> 
                 
                <!-- this control is used to send an email to the sales team, with any uploaded files already attached --> 
                <Email:EmailTemplate  
                Server="127.0.0.1" 
                To="sales@example.com" 
                FromAddress="sales@example.com" 
                Subject="Email from website" 
                ID="Emailtemplate2"  
                EmailFormat="html" 
                AutoAttachUploads="true" 
                Runat=server> 
                </Email:EmailTemplate> 
  






			<table border="1" style="FONT:10pt arial">
				<tr>
					<td>First Name:</td>
					<td><input id="FirstName" runat="server" type=text NAME="FirstName"></td>
				</tr>
				<TR>
					<TD>Last Name:</TD>
					<TD><input id="LastName" runat="server" type=text NAME="LastName"></td>
				</TR>
				<TR>
					<TD>Company:</TD>
					<td><input id="CompanyName" runat="server" type=text NAME="CompanyName"></TD>
				</TR>
				<TR>
					<TD>Country:</TD>
					<TD>
						<asp:DropDownList id="Country" runat="server">
							<asp:ListItem Value="-1" Selected="True">--Choose One--</asp:ListItem>
							<asp:ListItem value="82">Afghanistan</asp:ListItem>
							<asp:ListItem value="83">Albania</asp:ListItem>
							<asp:ListItem value="84">Algeria</asp:ListItem>
							<asp:ListItem value="85">American Samoa</asp:ListItem>
							<asp:ListItem value="85">Other...</asp:ListItem>
						</asp:DropDownList>
					</TD>
				</TR>
				<TR>
					<TD>E-mail:</TD>
					<TD>
						<input  id="txtEmail" runat="server" type=text NAME="txtEmail">
					</TD>	
				</TR>
				<TR>
					<TD colSpan="2">
						<input Text="Notify me for updates" Checked="True" id="NotifyForUpdates" runat="server" NAME="NotifyForUpdates">
					</TD>						
				</TR>
				<tr>
					<td colspan="2">Enter any additional comments below.</td>
				</tr>
				<tr>
					<td colspan="2">
						<textarea id="AdditionalComments" runat="server" cols="30" rows="6" NAME="AdditionalComments"></textarea>
					</td>
				</tr>
				<tr>
					<td colspan=2>Attach any additional files</td>
				</tr>
				<tr>
					<td colspan=2><input type=file id=txtFile1 runat=server NAME="txtFile1"></td>
				</tr>				
				<tr>
					<td colspan=2><input type=file id="txtFile2" runat=server NAME="txtFile2"></td>
				</tr>
				<tr>
					<td><input type=reset id=cmdReset value="Reset" runat=server NAME="cmdReset"></td>
					
					<td align="right">
						<input type="submit" value="Submit"  id=cmdSubmit runat=server NAME="cmdSubmit"></td>
				</tr>
			
			</table>
			<P>&nbsp;</P>
			<P>&nbsp;</P>
		</form>
	</body>
</HTML>




  
========================================== 
Confirm.txt File 
==========================================\ 
Hi ##FirstName## ##LastName##, 
Thanks for your comments. We will be contacting you shortly. 
  
Acme Sales Team 
  
  
========================================== 
Confirm.htm File 
========================================== 
<P>Hi ##FirstName## ##LastName##, 
</P> 
<P>Thanks for your comments. We will be contacting you shortly. 
</P> 
<P>Acme Sales Team 
    <BR> 
</P>