Save as Html File

The following example outputs the submitted form to a html file. It is important to note the destination directory needs write permissions to save the file. The FileOutputPath can be a relative or absolute directory path. The resulting file name is used as a template to generate the final file name. In this example results.htm is used, and a filename results.[n].htm will be generated where [n] is the number of files that already exist - 1. For example, if 2 files have already been generated, there will be two files in the directory named results.0.htm and results.1.htm. The next file generated will be results.2.htm. The TextFormat property controls the format of the text file. This format can either be plain text, html, or the rendered html of the page.


[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 will save the result of the form to a html text file in table format.-->
                <Email:EmailTemplate  
                Server="127.0.0.1" 
                To="sales@example.com" 
                FromAddress="webmaster@example.com" 
                Subject="Email from website" 
                ID="Emailtemplate1"  
                OutputType="TextFile"             
                TextFormat="Html" 
                FileOutputPath="results.htm" 
                Runat=server> 
                </Email:EmailTemplate> 





			<table border="1" style="FONT:10pt arial">
				<tr>
					<td>First Name:</td>
					<td><input id="FirstName" runat="server" type=text></td>
				</tr>
				<TR>
					<TD>Last Name:</TD>
					<TD><input id="LastName" runat="server" type=text></td>
				</TR>
				<TR>
					<TD>Company:</TD>
					<td><input id="CompanyName" runat="server" type=text></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>
					</TD>	
				</TR>
				<TR>
					<TD colSpan="2">
						<input Text="Notify me for updates" Checked="True" id="NotifyForUpdates" runat="server">
					</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"></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>