Beginner Problems

S

simchajoy2000

Hi,

This question will probably be too simplistic for all of you, but I am
trying to teach myself asp and I am having all sorts of problems. I
have a simple html form which calls process.asp on submit:

<html>
<head></head>
<body>
<form action="process.asp" method=Post>
<table cellpadding="0" cellspacing="5" align=center>
<tr>
<td width="100"><font color="#1B157F">Name:</font></font></td>
<td><input type="text" name="txtName" size="55"></td>
</tr>
</table>
<input type="submit" name="Submit" value="Submit Now">
</form>
</body>
</html>

I want my process.asp page to display the name the user entered and
then to send an email containing the information. Here is what I have
so far for the process.asp page:

<html>
<head></head>
<body>
<%
Dim strEmail

Dim strName
strName = Request.Form("txtName")
Response.Write strName

Set MyCDONTSMail = CreateObject("CDONTS.NewMail")
MyCDONTSMail.From = "(e-mail address removed)"
MyCDONTSMail.To = "(e-mail address removed)"
MyCDONTSMail.Subject = "Get-A-Quote Request from " & strName
MyCDONTSMail.Body = MyBody
MyCDONTSMail.Send
Set MyCDONTSMail = Nothing
%>
</body>
</html>

I am not trying to get this to run on a webserver at this point. I am
just trying to get it run in a regular folder on my computer. I
thought that might be the reason why I wasn't receiving any email but
then the Response.Write doesn't work either. When I don't add the html
tags I get a message that asks if I want to save or open the
process.asp page instead of just running it.

A little help? I'm obviously missing something . . . any advice would
be greatly appreciated!

Thank you!

Joy
 
R

Ray Costanzo [MVP]

Hi Joy,

No, you're off to a fine start (aside from the fact that you're using 1990s
technology...). But ASP files MUST be processed by a Web server. You can
probably run this locally on your machine. What are the answers to these
questions:

1. What operating system are you running?
2. Do you have IIS installed, do you know?

Ray at home
 
S

simchajoy2000

Thanks Ray,

I do have IIS installed and I am running Windows XP. However, the
webpage will not reside on my computer however. What do I need to do?

Joy
 
R

Ray Costanzo [MVP]

The web page ~will~ not but currently does? That's fine. That's normal.
In a default IIS setup, your "home page" for your site should reside in
C:\Inetpub\wwwroot. Put your ASP files there and test them by going to
http://localhost/yourpagename.asp

NOW, other things:

CDONTS = CDO for NT Server. You're running Windows XP. It does not have
CDONTS. If you installed the SMTP service when you installed IIS, you'll
have CDOSYS. Read this: http://www.aspfaq.com/show.asp?id=2026 Depending
on your setup where you're working, the e-mails may not actually be sent.
Like, if you're a bank teller playing with ASP files in between customers
and you start trying to relay e-mail from your site, it probably won't go.
Instead, you may wind up getting a call from a network admin asking why your
machine is trying to relay mail. I suggest that you just stop the SMTP
service and test the success of your ASP code by verifying that the mail was
placed in C:\Inetpub\mailroot\pickup, if it turns out that you cannot relay
mail from your machine.

Ray at home
 
S

simchajoy2000

Thank you so much Ray, I have done as you instructed and I placed the
folder containing all my html and asp files in C:\Inetpub\wwwroot and
then I created a virtual directory in IIS that points to that folder (I
was supposed to do that right?) but when I say
http://localhost/yourpagename.asp - it says the page cannot be
displayed - do you have any idea what is wrong?

Thanks!

Joy
 
S

simchajoy2000

Ok, silly me, I just needed to add the folder name to the path -
another question - I understand why the CDONTS doesn't work but
Response.Write doesn't work at all either. Can you tell from my code
if I am doing anything wrong?

Thanks!

Joy
 
L

Larry Bud

Thank you so much Ray, I have done as you instructed and I placed the
folder containing all my html and asp files in C:\Inetpub\wwwroot and
then I created a virtual directory in IIS that points to that folder (I
was supposed to do that right?) but when I say
http://localhost/yourpagename.asp - it says the page cannot be
displayed - do you have any idea what is wrong?

If you're using IE, make sure in Internet Options that "Show Friendly
HTTP error messages" is turned OFF.

This way the browser will tell you exactly where the error is occurring
in the ASP. There could be a syntax error on line 1, and you'd never
know it.
 
R

Ray Costanzo [MVP]

Show us your current code that you have now, and what does "doesn't work"
mean? Do you get an error? What does it say? Do you get a blank page?

Also, did you read what I wrote about how CDONTS hasn't really been in vogue
since 1999?

Ray at home
 
F

firas489

Hello (e-mail address removed),
About the CDOSYS as Ray Costanzo [MVP] said, he is correct, but in
addition when you declare and set the variable, i noticed that you
wrote Set MyCDONTSMail = CreateObject("CDONTS.NewMail")
Its better to write Set MyCDONTSMail =
Server.CreateObject("CDONTS.NewMail")
I know that you might say that "what did u add the server, i doesn't
make any difference" but trust me, when u program using Microsoft
programs, everything is possible. For example once i was using
MapPath("Location.mdb") and always getting an error, but couldn't find
it, then i had an idea, which was to add server to the command, so it
looked like this Server.MapPath("Locatuo.mdb"), after that the page
worked propoply with no extra problem, and by the way when u click
Ctrl+Space in Microsoft Visual InterDev you will find that MapPath
works without the Server as well as the CreateObject.


Hope this helps


Best Regards
Firas S Assaad
 
B

Bob Barrows [MVP]

Hello (e-mail address removed),
About the CDOSYS as Ray Costanzo [MVP] said, he is correct, but in
addition when you declare and set the variable, i noticed that you
wrote Set MyCDONTSMail = CreateObject("CDONTS.NewMail")
Its better to write Set MyCDONTSMail =
Server.CreateObject("CDONTS.NewMail")


In older versions of IIS, this did make a difference. In newer versions, the
recommendation is to use the vbscript version of CreateObject, rather than
the version provided by the Server object. For more information, see:

http://blogs.msdn.com/ericlippert/archive/2004/06/01/145686.aspx
 
P

Paxton

Thank you so much Ray, I have done as you instructed and I placed the
folder containing all my html and asp files in C:\Inetpub\wwwroot and
then I created a virtual directory in IIS that points to that folder (I
was supposed to do that right?) but when I say
http://localhost/yourpagename.asp - it says the page cannot be
displayed - do you have any idea what is wrong?

Thanks!

Joy

Just a thought.... but are you actually typing
"http://localhost/yourpagename.asp" into the address bar of the
browser?

If so, you should replace "yourpagename.asp" with the name of the
directory you created, then "/" then the name of the html file you
created (with ".html" on the end).

/P.
 
D

Dave Anderson

Bob said:
In older versions of IIS, this did make a difference. In newer
versions, the recommendation is to use the vbscript version of
CreateObject, rather than the version provided by the Server object.
For more information, see:
http://blogs.msdn.com/ericlippert/archive/2004/06/01/145686.aspx

How on Earth do you get any recommendation out of Lippert's article?

On the contrary, one of the comments suggests that this approach voids
connection pooling, and that would certainly give me pause.



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 
B

Bob Barrows [MVP]

Dave said:
How on Earth do you get any recommendation out of Lippert's article?

Yes, you're right. My bad. Eric made no recommendations. I had a
recommendation made in a post by Egbert Nierop
(http://groups.google.com/group/microsoft.public.inetserver.asp.general/msg/
409380a9492fb9c8?hl=en&) in the back of my mind when I wrote the above. He
had done some testing and come to the conclusion that using the Server
version was not only unnecessary in IIS5+, but that it also impaired
performance.

Here's a another quote:

WEll, quite simple. IIS 3/4 supported transaction management COM integration
using Server.Createobject. This statement, passes the COM context from ASP
to the inner component.
As of Windows 2000, this is no longer needed because of native COM support
for transactions and context passing, and it even slows down execution. On
windows 2000, it will process exception on components, that have no thread
affinity (C++).
On the contrary, one of the comments suggests that this approach voids
connection pooling, and that would certainly give me pause.
Yes, me too. But this was not stated by Eric, and was not substantiated by
the person who brought it up.

Bob Barrows
 
D

Dave Anderson

Bob said:
I had a recommendation made in a post by Egbert Nierop (
http://groups.google.com/group/microsoft.public.inetserver.asp.general/msg/409380a9492fb9c8?hl=en
&) in the back of my mind when I wrote the above.

Fair enough.


He had done some testing and come to the conclusion that
using the Server version was not only unnecessary in IIS5+,
but that it also impaired performance.

When I read his post, I had a reaction similar to yours below.


Yes, me too. But this was not stated by Eric, and was not
substantiated by the person who brought it up.

Like you, I would have liked something concrete. And that is why I merely
said it would give me pause. In truth, I do not feel that EITHER assertion
was backed up with substance, so neither would be likely to change my
practices.

If I thought I had a limitless number of ASP-coding days ahead of me, I
might spend some time exploring the issues in order to convince myself one
way or the other. But let's face it -- most of us will be doing less and
less with ASP in the future, so why waste the time looking for a cycle here
and there? It's not as if anyone suggested that either approach would cause
some type of cascading performance issue...



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 
B

Bob Barrows [MVP]

Dave said:
Fair enough.




When I read his post, I had a reaction similar to yours below.
I suspected that would be your response, and after posting the above, tried
to find the post that really convinced me, but could not find it, so as you
say later on in your reply, it's time to move on.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,132
Latest member
TeresaWcq1
Top