views:

43

answers:

3

hi

I have this form

<form action="http://www.mysite.com/asp/formd.asp" method="post" target="_blank">

so the asp looks like below,

it opens a new window where ot says "send ok"

my question is how and where can I contro/define the style of this new window i.e background fonts color etc thanks

the ASP code:

<%@ Language=VBScript %>

<%

Dim txtbody
Dim objCDO
Set objCDO = Server.CreateObject("CDONTS.NewMail")

objCDO.To = "[email protected]"
objCDO.From = "[email protected]"
objCDO.Subject = "* *Formu enviado desde web * *"

txtbody = ""
for a = 1 to Request.Form.Count
 txtbody = txtbody & Request.Form.Key(a) & " = " & Request.Form(a) & chr(10) & chr(13)
next

for a = 1 to Request.QueryString.Count
 txtbody = txtbody & Request.QueryString.Key(a) & " = " & Request.QueryString(a) & chr(10) & chr(13)
next

txtbody = txtbody & "*******-----------------******"

objCDO.Body = txtbody

objCDO.Send

Response.Write "send = Ok"

%>
A: 

If you'd like to have a page or message that's more meaningful, consider replacing this

Response.Write "send = Ok"

with this:

Response.Redirect "email-thank-you.htm" 'or .asp, whatever you like.

Then go make your new page email-thank-you.htm as decorated and styled as nicely as you can. This helps by having your email logic contained in one page or function, and separate from the nice page. If something happened, i.e. the email server was unavailable, or perhaps the email address was malformed/missing, you could write that back to the original page.

p.campbell
great thanks thats what I was looking for !
qaedus
A: 

If I understand what you're doing correctly, you should actually create a static form called emailForm.asp with your desired styling. Have it read the querystring that you are passing and and place the values in the fields. Put on link on your current page in order to pop this page up.

MCain
A: 

Your final line, Response.Write "send = Ok" is being output as a badly-formed html page.

I'd recommend you structure your page as follows:

<%@ Language=VBScript %>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
<html>
<head>
 <!-- Add header info, including links to style sheets -->
</head>
<body>
<%
'Your CDO code goes here

  objCDO.Send

  if err.number > 0 then
    response.write "<p class='error'>Error: " & err.number & " - " & err.message & "</p>"
  else
    Response.write "<p class='ok'>Sent OK</p>"
  end if
%>
</body>
</html>

This will render a full html page that you can style properly (and will also no presume that the email sent OK!).

CJM
thanks ! how do implement the err message?would Response.write "<p class='ok'>"email-thank-you.htm"</p>" also works?
qaedus
My example outputs a success message or an error message. You could have it redirect to a 'email-thank-you.htm' page but it's less efficient (another round-trip to the server). If you want to redirect to a 'success' page or an error page, replace the Response.Write with a Response.Redirect "another_page.htm". TBH I think you should take a step back and do some basic HTML/CSS/ASP tutorials - this is basic stuff.
CJM