Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 24th, 2004, 01:20 PM
Registered User
 
Join Date: May 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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>
 
Old May 24th, 2004, 01:40 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Try this:

If Err.Number = 0 Then
Response.Write("<script language=""JavaScript"">var msg = ""Message Sent!""; alert(msg);</script>")
Response.Redirect("mailtest.asp")
Else
Response.Write Err.Description & ""
Err.Number = 0
End If
On Error Goto 0


 
Old May 24th, 2004, 02:09 PM
Registered User
 
Join Date: May 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks..still not successful..maybe I'm putting the code in the wrong place...

I put your suggestion in place of here:

 If Err <> 0 Then ' error occurred
      strErr = Err.Description
   else
      bSuccess = True
   End If

Is this the right place? I'm still not getting a fresh page

Thanks
Amy
 
Old May 24th, 2004, 02:27 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Try:

If Err <> 0 Then ' error occurred
    strErr = Err.Description
else
    Response.Redirect("thankyou.asp")
End If



 
Old May 24th, 2004, 03:38 PM
Registered User
 
Join Date: May 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

HOLY COW!...

Finally figured out where to put the code and what would work with what..and it works!

Thanks for the tips!

Amy





Similar Threads
Thread Thread Starter Forum Replies Last Post
Confirm messagebox edwin.debrouwere ASP.NET 2.0 Basics 0 September 5th, 2006 07:29 AM
a problem of adding a confirm window to delete but raybristol ASP.NET 1.0 and 1.1 Basics 1 December 12th, 2005 05:01 PM
a problem of adding a confirm window to delete but raybristol ADO.NET 1 December 12th, 2005 04:50 PM
confirm crmpicco Javascript How-To 2 February 7th, 2005 01:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.