Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send form data so it is received as an HTML page? 1

Status
Not open for further replies.

Nottoobright

Technical User
Oct 10, 2001
17
0
0
GB
Hi,
I have a form that the user fills in with data and then uses a calculate button at the bottom to add up the entered costs. The user has to be able to enter an email address click send and the form will be sent to that address.

How do I do it so that the reciever will recieve the form in the same format as it was sent ie. the web page complete with data, so that it makes sense.

Can anyone help?

Thanks.
 
Do you already have a solution in place that will automatically send an email to the user, whether a web page or just basic text ??

If you don't, that's where you are going to need to start first. I use ASP server side technology for my entire application and it provides a Mail object that allows my ASP pages to send emails.

Where do we stand with that ??

TW
 
At the minute I am just using the submit button on the form and the method post attribute. Like this:

<form name=&quot;form1&quot; action=&quot;mailto:lp@icrgroup.co.uk&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;>

But it sends it in a really wierd format that I can't open. So ideally I would like it to send a copy of the web page complete with data as an attachment so the reciever can then print it out. Any ideas?
 
You're going to want a server side solution to do this. Are you running your web site on an NT or W2K server ?? If so, I can provide some further assistance.

TW
 
OK. Let's run a quick test.

Setup a test page. Call it testmail.asp. Type this in.


<%@ Language=VBScript %>
<% Option Explicit %>
<% Response.Buffer = True %>

dim mail

set mail = Server.CreateObject(&quot;CDONTS.NewMail&quot;)
mail.to = &quot;youremailaddress&quot;
mail.from = &quot;youremailaddress&quot;
mail.subject = &quot;TEST Mail&quot;
mail.body = &quot;This is a test message on Line 1.&quot; & chr(13) _
& &quot;This is a test message on Line 2.&quot;
mail.send
set mail = Nothing
%>


Fill in the to and from email addresses (inside quotes) and save the file and run it from a browser. Make sure it has the extension .asp.

If you're running this on your own web server, the SMTP server must be running for the mail to be successfully sent, and it may well already be running for other obvious reasons. If you're on a HOST, more than likely they have it turned on for you by default.

One of three things are going to happen.

#1: You get an error.

#2: You get a blank page. But no email ever arrives to you.

#3: You get a blank page AND you also get the mail.


In any case, let me know what happened and provide anything that came up in the browser when you ran that page. Technically, the browser window should be blank when you run it.

ToddWW
 
Ok I used your code and it just wrote it out on the screen so I included another <% tag (Not sure if you missed it out, shown underneath) and i just got a blank screen and no email.

<%@ Language=VBScript %>
<% Option Explicit %>
<% Response.Buffer = True %>
<%
dim mail

set mail = Server.CreateObject(&quot;CDONTS.NewMail&quot;)
mail.to = &quot;pk068917@stmail.staffs.ac.uk&quot;
mail.from = &quot;pk068917@stmail.staffs.ac.uk&quot;
mail.subject = &quot;TEST Mail&quot;
mail.body = &quot;This is a test message on Line 1.&quot; & chr(13) _
& &quot;This is a test message on Line 2.&quot;
mail.send
set mail = Nothing
%>
 
OK, great. You're right, my stupidity on the ASP tag. We're half way home (or more) if you did not receive any errors. Just to be sure that the server is parsing the code, View the source of the blank page. It should also be blank. Let me know.

I'm going to ask you to wait an hour or so to see if the email eventually comes. I would hate to troubleshoot that for the next few hours and then all of the sudden the mail arrives in your inbox.

Is this website on your own server or are you having it hosted by a hosting company ??

Reply back if you have not received the email in the next hour.

ToddWW
 
It is hosted on our on Creek server. I don't understand about the SMPT server thingy that you mentioned earlier though.
This is the source code that the page shows:

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<HTML><HEAD>
<META content=&quot;text/html; charset=windows-1252&quot; http-equiv=Content-Type></HEAD>
<BODY></BODY></HTML>

I will wait an hour and see if the email arrives.
Thanks.
 
I'm not sure what a Creek server is so I'm just going to continue to assume you're using Windows NT. Do you personally have access to that servers desktop, or do you have to make requests to someone else for that ??

TW
 
Try changing your enctype to text/html. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
I have access to the servers desktop. I tried to change the anctype to text/html but it is still sending it through in a format my computer can not understand.
 
First check with your security buffs to make sure you can do this. Then go to the Internet Services Manager for Internet Information Services from Start/Administrative Tools. I'm still assuming your running on Windows NT or MS 2000 Server.

Start the SMTP Server. (This allows ASP to send outbound mail)

I did not need to do any configuration on my SMTP. I just started it and it's been processing my ASP mail perfectly ever since.

TW
 
Yes running Windows NT, but still no mail. SMPT is already set up I have been told.
 
It turns out that the server I am testing it on is only an internal server and the firewall is preventing it from sending mail out my email. But the emails are getting through to it and it is logging them on the queue just not sending them. I can check the content of the emails from that machine.
Will it be possible to test the form from there?
 
Yes, you should be able to bring up those emails from the remote queue and they'll display just as they would when sent to a visitor. So, yes if you don't mind going over to the server and bringing the email files up from the queue to see how they look, it will work..

Now, did you see the email that we setup and sent earlier ?? Did everything look in order.. ie. addressee, subject line, email body ??

If that was all in order, I can write the solution for you to send HTML emails including forms, etc... so the email will look exactly like a web page. (Just like those annoying advertisements you get in your inbox everyday)

I want to make sure that looked good so we won't have to troubleshoot that later..

TW
 
Everything was in order, it all seemed fine.
Thankyou for all this help Todd
 
OK the, try this HTML version. The HTML goes in the body of the email. You can write just about anything in there, including a form. When the submit button is pressed on the form, a new browser window will open with a confirmation page, if you design it that way. Plus I've added two more parameters. Mail.BodyFormat and Mail.MailFormat. These are set for HTML mail.


<%@ Language=VBScript %>
<% Option Explicit %>
<% Response.Buffer = True %>
<%
dim mail

set mail = Server.CreateObject(&quot;CDONTS.NewMail&quot;)
mail.to = &quot;pk068917@stmail.staffs.ac.uk&quot;
mail.from = &quot;pk068917@stmail.staffs.ac.uk&quot;
mail.subject = &quot;TEST HTML Mail&quot;
mail.body = &quot;<html><head></head><body>&quot; _
& &quot;<font size='3' color='#FF0000'><strong>&quot; _
& &quot;Hello, this is an HTML email&quot; _
& &quot;</font></strong>&quot; _
& &quot;</body></html>&quot;
mail.BodyFormat = 0
mail.MailFormat = 0
mail.send
set mail = Nothing
%>


Hope this gets you what or originally wanted.

TW
 
Thankyou very much Todd that is working great. One last question to get the data that the user has already entered into the form I am using

value=request.form(d1)

to insert it as the value of the relevant text box. Where do I put the apostrophies (sp?) in that because at the moment it writing that as the value instead of the actual value.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top