Assonet River Design Group : Portfolio : Code Snippets : Contact

Two snippets of code are inserted using the ASP Server Behavior ASPEmail Form for Dreamweaver UltraDev.

(a) First block is inserted above the </html> tag. This executes the ASPEmail script and uses the values passed from the form.

(b) The second block inserts a form named 'ASPEmail_Form' and required fields for CDO.

-- don't have UltraDev - or just want the code? then copy below and paste into a blank .asp page --

<%@LANGUAGE="VBSCRIPT"%>
<%
' ASPEmail Server Behavior Form 1.0.4 for Dreamweaver UltraDev
' Pete Erwin http://www.assonetriver.com
'
' To add more info to the Body of your email message:
' 1) comment in the '& vbcrlf&_ at the end of the Mail.Body line
' 2) edit the Additional Fields shown as examples
'
' NOTE: This server requires ASPEmail Server Component to be installed on your web server
' visit http://www.aspemail.com for more details
If Request.Form("submit") = "Submit" Then
Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = "mail.yourserver.com" ' Specify a valid SMTP server mail.yourserver.com
Mail.From = cStr(Request("varFrom")) 'Senders Email Address
Mail.FromName = cStr(Request("varFromName")) ' Specify sender's name
Mail.AddAddress cStr(Request("varTo")) 'Recipient Email Address
Mail.AddCC cStr(Request("varCC")) 'Carbon Copy Email Address
Mail.Subject = cStr(Request("varSubject")) 'Email Subject
Mail.Body = cStr(Request("varBody")) '& vbcrlf&_
' "Additional Field1 Value Name: " & cStr(Request("varYourField1"))& vbcrlf&_
' "Additional Field2 Value Name: " & cStr(Request("varYourField2"))& vbcrlf&_

On Error Resume Next
Mail.Send
Set Mail = Nothing 'Clean up your objects!!!
If Err <> 0 Then
Response.Write "Error encountered: " & Err.Description
End If

'Response.Redirect("thanks.asp") 'comment this in to use this to redirect page after delivery
Response.Write("Message Delivered") 'default response

End If
%>
<html>
<head>
<title>ASPEmail Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<!-- Start ASPEmail Email Form
// field values in this form will be sent via email using ASPEmail server component
-->
<form name="ASPEmail_Form" method="post" action="">
<table cellpadding="1" cellspacing="1" border="1">
<tr>
<td width="158">From Email Address</td>
<td width="280">
<input type="text" name="varFrom" size="50">
</td>
</tr>
<tr>
<td width="158">From Name</td>
<td width="280">
<input type="text" name="varFromName" size="50">
</td>
</tr>
<tr>
<td width="158">To</td>
<td width="280">
<input type="text" name="varTo" size="50">
</td>
</tr>
<tr>
<td width="158">CC</td>
<td width="280">
<input type="text" name="varCC" size="50">
</td>
</tr>
<tr>
<td width="158">Subject</td>
<td width="280">
<input type="text" name="varSubject" size="50">
</td>
</tr>
<tr>
<td width="158">Message</td>
<td width="280">
<textarea name="varBody" cols="50" rows="5"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" name="Submit" value="Submit">
</td>
</tr>
</table>
</form>
<!-- End ASPEmail Form -->
</body>
</html>