Click to See Complete Forum and Search --> : Displaying a new page


Mimorkeris
06-02-2005, 03:08 AM
I downloaded 2 ASP pages from my ISP to allow visitors to website to send Emails whilst keeping address hidden (well at least atempt to).

They work OK, but, the form which sends the email then advises the visitor if it was sent or not very crudely.

I would like to be able to open/load a new page which is more informative, but I my knowledge of ASP is very limited, so any help would be greatly appreciated.

The other thing that springs to mind is - how do I carry forward the the data from the either the previous or this page page to the next?

Here is the code from the page: -

<html>
<head>
<title>ASPSend mail example</title>
</head>

<body>

<%
'Getting (Requesting) the Session variables from Form on previous page
Session("FromName") = Request("FromName")
Session("FromAddress") = Request("FromAddress")
Session("Subject") = Request("Subject")
Session("BodyText") = Request("BodyText")

Set Mailer = Server.CreateObject("SMTPsvg.Mailer")

'Setting variables
Mailer.FromName = Session("FromName")
Mailer.FromAddress = Session("FromAddress")
Mailer.RemoteHost = "smtpmail.activeisp.com"
Mailer.AddRecipient "Mail Recipient", "admin@acompany.com"
Mailer.Subject = Session("Subject")
Mailer.BodyText = Session("BodyText")

'Checking if mail sent ok, if not display error message
if Mailer.SendMail then
Response.Write "Thank you for contacting us, we will respond within the next working day."
Response.Write "Do not respond to this automated message."
else
Response.Write "Mail send failure. Error was " & Mailer.Response
end if

'Abandoning session variables
Session.Abandon
%>

</body>
</html>

buntine
06-02-2005, 03:58 AM
You will need to alter the following If statement:

'Checking if mail sent ok, if not display error message
If Mailer.SendMail Then
Response.Redirect("yourFileGoesHere")
Else
Response.Write "Mail send failure. Error was " & Mailer.Response
End If

Replace YourFileGoesHere with the URL of the file you want to display a nicer message. For example, you could create a file named thankyou.html that just says thankyou to the user, etc. The If Statement would then look like this:

'Checking if mail sent ok, if not display error message
If Mailer.SendMail Then
Response.Redirect("thankyou.html")
Else
Response.Write "Mail send failure. Error was " & Mailer.Response
End If

Regards.

Mimorkeris
06-02-2005, 06:34 AM
Thanks for this, I spent ages last night wading around the webb and looking for answer in 1200 page wrox book until I couldn't see the wood for trees.

thanks again, Mimorkeris

buntine
06-02-2005, 07:47 AM
No worries. ;)