Confirm Window AND email sent
Hi all
I'm fairly green at asp, so I need help. I'm doing a form where the user fills out the form, hits submit and I want it to put up a confirming message on a different page to the user AND send an email to the person at the company who needs to respond (which will always be the same person).
I am using asp email and can get a confirming message at the top of the input page, but the powers that be want a clean, new page confirming the submission.
Note: action="mailtest.asp" redirects to itself. I can't get it to send an email if the parameters are passed to a different page.
Any help would be appreciated...
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
' change to address of your own SMTP server
strHost = "correct host here"
If Request("Send") <> "" Then
Set Mail = Server.CreateObject("Persits.MailSender")
' enter valid SMTP host
Mail.Host = strHost
Mail.From = Request("From") ' From address
Mail.FromName = Request("FromName") ' optional
Mail.AddAddress Request("To")
' message subject
Mail.Subject = Request("Subject")
' message body
Mail.Body = Request("Body")
strErr = ""
bSuccess = False
On Error Resume Next ' catch errors
Mail.Send ' send message
If Err <> 0 Then ' error occurred
strErr = Err.Description
else
bSuccess = True
End If
End If
%>
<HTML>
<BODY BGCOLOR="#FFFFFF">
<% If strErr <> "" Then %>
<h3>Error occurred: <% = strErr %>
<% End If %>
<% If bSuccess Then %>
Success! Message sent to <% = Request("To") %>.
<% End If %>
<FORM METHOD="POST" ACTION="mailtest.asp">
<TABLE CELLSPACING=0 CELLPADDING=2 BGCOLOR="#E0E0E0">
<TR>
<TD>Host (change as necessary in script):</TD>
<TD><B><% = strHost %></B></TD>
</TR>
<TR>
<TD>From (enter sender's address):</TD>
<TD><INPUT TYPE="hidden" NAME="From" ></TD>
</TR>
<TR>
<TD>FromName (optional, enter sender's name):</TD>
<TD><INPUT TYPE="hidden" NAME="FromName" value="Ames"></TD>
</TR>
<TR>
<TD>To: (enter one recipient's address):</TD>
<TD><INPUT TYPE="TEXT" NAME="To"></TD>
</TR>
<TR>
<TD>Subject:</TD>
<TD><INPUT TYPE="hidden" NAME="Subject" value="Info"></TD>
</TR>
<TR>
<TD>Body:</TD>
<TD><INPUT TYPE="hidden" NAME="Body" value="Your information has been passed on"></TD>
</TR>
<TR>
<TD COLSPAN=2><INPUT TYPE="SUBMIT" NAME="Send" VALUE="Send Message">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
|