|

DOWNLOAD
Reference
ASP Examples
WebMail Example
Send
an Email from an HTML form
This example demonstrates using an HTML form to
collect information and send Email.
This is the HTML form:
<HTML>
<HEAD>
<TITLE>Chilkat WebMail Example: Send an Email from an HTML form</TITLE>
</HEAD>
<BODY>
<form method="post" action="send_email.asp">
<p>Fill out this form, click Submit, and your email will be sent.<br>
</p>
<table width="75%" border="0">
<tr>
<td width="42%" nowrap>
<div align="right">Your Name</div>
</td>
<td width="58%">
<input type="text" name="fromName" size="40">
</td>
</tr>
<tr>
<td width="42%" nowrap>
<div align="right">Your Email Address</div>
</td>
<td width="58%">
<input type="text" name="fromAddress" size="40">
</td>
</tr>
<tr>
<td width="42%" nowrap>
<div align="right">Recipient Name</div>
</td>
<td width="58%">
<input type="text" name="toName" size="40">
</td>
</tr>
<tr>
<td width="42%" nowrap>
<div align="right">Recipient Email Address</div>
</td>
<td width="58%">
<input type="text" name="toAddress" size="40">
</td>
</tr>
<tr>
<td width="42%" nowrap>
<div align="right">Subject</div>
</td>
<td width="58%">
<input type="text" name="emailSubject" size="40">
</td>
</tr>
<tr>
<td height="163" valign="top" width="42%" nowrap>
<div align="right">Email Text</div>
</td>
<td height="163" width="58%">
<textarea name="emailText" cols="60" rows="10"></textarea>
</td>
</tr>
</table>
<p>
<input type="submit" value="Submit">
</p>
<!-- End of HTML Email Form for Sending Mail -->
</form>
</BODY>
</HTML>
|
This is the form target (send_email.asp):
<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<HEAD>
<TITLE>Chilkat WebMail Example: Send an Email from an HTML form</TITLE>
</HEAD>
<BODY>
Sending email from an HTML form....<br><br>
<%
' Create a mailman. The mailman can send and receive Email.
set mailman = Server.CreateObject("ChilkatWebMail.WebMailMan")
' Unlock the component - use your trial or purchased unlock code.
mailman.UnlockComponent "unlock_code"
' Tell the mailman where the SMTP server is located
mailman.SmtpHost = "smtp.my_company.com"
' Create an empty Email message
set email = Server.CreateObject("ChilkatWebMail.WebEmail")
' Enter the recipient's information from form variables.
email.AddTo Request.Form("toName"), Request.Form("toAddress")
' Enter the sender's information from form variables.
email.FromName = Request.Form("fromName")
email.FromAddress = Request.Form("fromAddress")
' Enter the email subject
email.Subject = Request.Form("emailSubject")
' Enter the email text
email.Body = Request.Form("emailText")
' Send the email
if mailman.SendEmail(email) then
Response.write "Message sent successfully!<br><br>"
else
Response.write "ERROR: Message not sent!<br><br>"
end if
%>
<br>(View page source to see the log)
<XML ID="XMLID">
<%
Response.write mailman.GetInstanceLog()
%>
</XML>
<%
' Standard ASP cleanup of objects
Set email = Nothing
Set mailman = Nothing
%>
<BR>DONE.<BR>
</BODY>
</HTML>
|
*This ASP script source example demonstrated how to send an email
from an HTML form.
|
Privacy
Statement. Copyright 2000-2012 Chilkat
Software, Inc. All rights reserved.
(Regarding the usage of the Android logo) Portions of this page are reproduced from work created and shared by Google
and used according to terms described in the Creative Commons
3.0 Attribution License.
Send feedback to support@chilkatsoft.com
Software components and libraries for Linux, MAC OS X, IOS (IPhone), Android™, Solaris, RHEL/CentOS Microsoft Windows 7, Vista, XP, 2000, 2003 Server, 2008 Server, and Windows 95/98/NT4.
|
|