ASP Email
Want to add a contact us screen to your site but hide your email address?
Below is a sample and code to do just that.
This code uses the CDONT ASP Activex object to send mail
This is the code for the sender and form
Place this form and this script on your page
<%
dim s_from, s_url, s_msg, rtn_msg, s_send_addr, rtn
'--------------------------------------------------
'Set to your return address
s_send_addr= "myemail@my_url.com"
'-----------------------------------------
' Do not change anything below this line
'-----------------------------------------
s_from = request("cemail")
s_name = request("cname")
s_url = request("curl")
s_msg = request("cmessage")
If len(s_from) = 0 or len(s_name) = 0 or len(s_msg) = 0 then response.redirect s_page & "?err=true" &_
"&u_email=" & s_from & "&u_msg=" & s_msg & "&u_name=" & s_name
If Len(s_from) <= 5 Then rtn = 1
If InStr(1, s_from, "@", 1) < 2 Then
rtn = 1
Else
If InStr(1, s_from, ".", 1) < 4 Then rtn = 1
End If
If rtn <> 0 then response.redirect s_page & "?err=true&type=ml&u_email=" & s_from & "&u_msg=" &_
s_msg & "&u_name=" & s_name
on error resume next
Set mail = Server.CreateObject ("CDONTS.NewMail")
if err = 0 then
mail.BodyFormat = 1
mail.MailFormat = 0
mail.Send s_from, s_send_addr, "mail from: " & s_name, s_msg
if err = 0 then
rtn_msg = "Your Mail has been Sent<br><br>We will try to get back to you as soon as we can.
Thank You"
else
rtn_msg = "Error Sending Mail: " & err.Description & "<br><br>Please email us at " & s_send_addr
end if
else
rtn_msg = "Mail Error: " & err.Description & "
Please email us at " & s_send_addr
end if
set mail = nothing
%>
<p align="center"><%=rtn_msg%></p>
Vincent Gabriele