CDONTS with ASP Part 2

A Sample User Interface for Sending Email Using CDONTS NewMail Object

Note, however, that our sample user interface does not provide a means for the client to specify an attachment. This is because the Request.Form method used to process the form is limited in that it only allows plain text upload, and users often wish to include attachments in alternative formats. If you wish to add attachment capability and support it fully, the Request.Form method must be augmented with additional software, e.g. dgFileUpload.

From:
* To:
* Cc:
* Bcc:
Subject:
BodyFormat: 
MailFormat: 
Importance: 
Body:
 
* Separate multiple addresses with semi-colons

Below is the code for the form. You will notice that JavaScript has been used to ensure the correct or needed fields have been filled in when the form is submitted.

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<html>
<head>
<title>A Sample Form for Sending Email Using CDONTS NewMail Object</title>
<script language=”JavaScript”>
// Function to make sure all required parameters are present
// before submission
function CheckSubmit()
{
if (document.mailform.FromField.value == “”)
{
alert(“Sender and at least one recipient must be specified.”)
return
}
if (document.mailform.ToField.value == “”)
{
if (document.mailform.CcField.value == “”)
{
if (document.mailform.BccField.value == “”)
{
alert(“Sender and at least one recipient must be specified.”)
return
}
}
}
document.mailform.submit()
}
</script>
</head>
<body>
<div align=”center”>
<h3> A Sample User Interface for Sending Email Using CDONTS NewMail Object</h3>
<P></P>
<form name=”mailform” action=”http://www.yourdomain.com/cgi-bin/cdontsmailreply.asp” method=”post”>
<table cellspacing=”2″ cellpadding=”5″ border=”0″>
<tr>
<td align=”right”><font color=red>From: </font></td>
<td><INPUT maxLength=100 name=FromField size=52></td>
</tr>
<tr>
<td align=”right”>* <font color=red>To: </font></td>
<td><INPUT maxLength=256 name=ToField size=52></td>
</tr>
<tr>
<td align=”right”>* Cc: </td>
<td><INPUT maxLength=256 name=CcField size=52></td>
</tr>
<tr>
<td align=”right”>* Bcc: </td>
<td><INPUT maxLength=256 name=BccField size=52></td>
</tr>
<tr>
<td align=”right”>Subject: </td>
<td><INPUT maxLength=100 name=SubjectField size=52></td>
</tr>
<tr>
<td align=”center” colspan=”2″>
BodyFormat:&nbsp;
<select name=BodyFormatField type=select>
<option value=”0″> Message contains HTML.
<option value=”1″ selected> Message contains plain text only.
</select>
</td>
</tr>
<tr>
<td align=”center” colspan=”2″>
MailFormat:&nbsp;
<select name=MailFormatField type=select>
<option value=”0″> Use MIME format.
<option value=”1″ selected> Use plain text format.
</select>
</td>
</tr>
<td align=”center” colspan=”2″>
Importance:&nbsp;
<select name=ImportanceField type=select>
<option value=”0″> Low importance.
<option value=”1″ selected> Normal importance.
<option value=”2″> High importance.
</select>
</td>
</tr>
<tr>
<td align=”right”>Body: </td>
<td><TEXTAREA cols=40 name=BodyField rows=12></TEXTAREA> </td>
</tr>
<tr>
<td align=”center” colspan=”2″>
<input name=”send” type=”submit” id=”send” value=”Send Mail”>
&nbsp; <input name=”reset” type=”reset” value=”Reset”> </td>
</tr>
<tr>
<td align=”center” colspan = “2”>
* Separate multiple addresses with semi-colons
</td>
</tr>
</table>
</form>
</div>
</body>
</html>

As you can see, the form data is posted to a file called cdontsmailreply.asp that contains the CDONTS code as discussed on the previous page. Next we will take a look at the code for this page.

Leave a Reply