PDA

View Full Version : ASP, HTM and CDO CODE


Mamdouh AMer
12-13-2009, 02:51 PM
i have a problem, i'm just a beginner in Asp and Html...

and i want to know how i can put the CDO code into my pages.

1. i don't know where i put this codes inside the page.
2. how i can connect the form which i created into the body mail.

and i will just copy the code pages from the frontpage as below:

please help me its so important......


<html dir="rtl">

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Quote Request</title>
</head>

<body>

<p>&nbsp;</p>
<p dir="ltr">&nbsp;</p>
<p dir="ltr" align="center"><u><b><font size="6">Quote Request</font></b></u></p>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="88%" dir="ltr">
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left"><u><b>Company Information:</b></u></td>
<td width="66%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">&nbsp;</td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p dir="ltr" align="left">Company Name:</td>
<td width="66%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p dir="ltr" align="left"><input type="text" name="compName" size="59"></td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p dir="ltr" align="left">Postal Address:</td>
<td width="66%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p dir="ltr" align="left"><input type="text" name="compName" size="59"></td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">City:</td>
<td width="66%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left"><input type="text" name="compName" size="59"></td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">Country:</td>
<td width="66%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left"><input type="text" name="compName" size="59"></td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">Phone Number:</td>
<td width="66%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left"><input type="text" name="compName" size="59"></td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">Fax Number:</td>
<td width="66%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left"><input type="text" name="compName" size="59"></td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">&nbsp;</td>
<td width="66%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">&nbsp;</td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">&nbsp;</td>
<td width="66%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">&nbsp;</td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left"><u><b>Contact Person Information:</b></u></td>
<td width="66%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">&nbsp;</td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">First Name:</td>
<td width="66%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left"><input type="text" name="compName" size="59"></td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">Last Name:</td>
<td width="66%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left"><input type="text" name="compName" size="59"></td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">Email Address:</td>
<td width="66%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left"><input type="text" name="compName" size="59"></td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">Mobile Number:</td>
<td width="66%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left"><input type="text" name="compName" size="59"></td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
&nbsp;</td>
<td width="66%" dir="ltr" nowrap bordercolor="#FFFFFF">
&nbsp;</td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">&nbsp;</td>
<td width="66%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">&nbsp;</td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left"><u><b>Service Information:</b></u></td>
<td width="66%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">&nbsp;</td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">P.O.L:</td>
<td width="66%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left"><input type="text" name="compName" size="59"></td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">P.O.D:</td>
<td width="66%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left"><input type="text" name="compName" size="59"></td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">goods description:</td>
<td width="66%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left"><input type="text" name="compName" size="59"></td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">&nbsp;</td>
<td width="66%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">&nbsp;</td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">&nbsp;</td>
<td width="66%" dir="ltr" nowrap rowspan="5" bordercolor="#FFFFFF">
<p align="left"><input type="text" name="compName" size="59"></td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">&nbsp;</td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">Additional notes:</td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap bordercolor="#FFFFFF">
<p align="left">&nbsp;</td>
</tr>
<tr>
<td width="34%" dir="ltr" nowrap>
<p align="left">&nbsp;</td>
</tr>
</table>
<form method="POST" action="--WEBBOT-SELF--" name="dform">
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" value="Submit" name="B1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="reset" value="Reset" name="B2"></p>
</form>
<p dir="ltr">&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>


</body>

</html>

vinyl-junkie
12-13-2009, 03:14 PM
I am assuming that you want to take some form data and have it stored in a database. In order to do that, you need to have some basic understanding of how ASP works. I would highly recommend that you first take a step back and read a tutorial, like this one (http://www.w3schools.com/asp/default.asp). After doing that, try writing the script that your form will process. If you run into anything you don't understand, post your form processing script, and we'll be glad to help.

Mamdouh AMer
12-13-2009, 07:39 PM
thanks so much this site help me alot. about ASP

but i didn't found how i can connect between the forms that i want the customer complete in order to be sending in the body mail...

for example if i use

Name: xxxxxxx
company: zzzzzzzzz

what is the codes that i should used in

<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.Bcc="someoneelse@somedomain.com"
myMail.Cc="someoneelse2@somedomain.com"
myMail.TextBody="This is a message." ???????????
myMail.Send
set myMail=nothing
%>

in order to make xxxxx and zzzzzz appear to me in the mail which i should get via CDO code...!!!!!

please advise

thanks again so much .................:thumbsup::)

vinyl-junkie
12-13-2009, 08:03 PM
This page (http://www.w3schools.com/asp/asp_inputforms.asp) in the W3Schools tutorial shows you how to access the variables from your form.

You really need to read through that whole tutorial, not just pick out the parts that contain code for what you want to do. Otherwise, you'll have no understanding of what you're doing.

Old Pedant
12-13-2009, 08:32 PM
You could also look at the thread RIGHT BELOW this one:
http://www.codingforums.com/showthread.php?t=184341

Exactly the same question, for all intents and purposes, with working answer.

Mamdouh AMer
12-14-2009, 12:37 PM
thanks so much.....

but i think i'm so stupid because i still not able to make the form body in the mail by using the CDO code...

so i attached me ASP file which i wanna to solve the problem in...

all my wondring is how to make the form appear in the body mail.
because every time i try something all i get is a blank mail without any data on it.............

so, pleasssssse heeeeeeeeeeeeeeeeeeeeeelp it's so important to meeeeee and my career :(

hoping anyone can help me about that....

just change the extension from TXT to ASP...

miranda
12-14-2009, 04:41 PM
I am not familiar with the webbots part of frontpage, however the principals of .asp are all the same.

OK you have all of the code on one page. so each time the page loads it is trying to send an email. But you have two variables that are not declared nor assigned a value so it throws an error on that line.

objMail.TextBody= emsg & fline

What are tha values of these supposed to be?

As to sending your form info you only really need one form tag.

The action attribute in the form tag indicates what page the form data is submitted to when the submit button is pressed. What is the name of this page? If this is not m.asp then it cannot send the email withthe form data. If it is m.asp the page is posting back onto itself. In classic asp you will need some way to distinguish if the page is a postback because you do not have the postback event offered by the .NET framework.

Now for each of the text inputs you need to get the values entered in them.
Because you have the method attribute in the form tag set to POST you can use the Request.Form method to get your values. This is done by simply doing
CompanyName = Request.Form("CompName")
PostalAddress = Request.Form("postalAdd")
City = Request.Form("City")
and so forth

Now it gets a bit tricky when it is a postback so if you are indeed posting the form back onto itself you will need to either check to see if one the form fields have values in them or check to see if the button was pressed. This is done by doing something like this
<%
If Request.Form("B1") = "Submit" Then
'Add the code to process the sending of the form here
End If
%>



Now since you are sending a plain text based message you will probably want to have the line breaks this can be done 2 different ways. the easiest is to use VbCrLf. Then since i am making one big string I am using & _ to tell the code that the string is continued on the next line.

I am assuming by the location of the button inside a second form tag that once the email is sent you want to take the user to 11.htm so I will use the Server.Transfer method to move the user to that page.


that's really all there is to it

Here is part of your code all you need to do is finish the assigning of variables and put them into the string that contains the email message

<%
If Request.Form("B1") = "Submit" Then
Dim sendUrl
Dim smtpUrl
Dim objConfig
Dim objMail
Dim CompanyName
Dim PostalAddress
Dim City
Dim emsg

sendUrl="http://schemas.microsoft.com/cdo/configuration/sendusing"
smtpUrl="http://schemas.microsoft.com/cdo/configuration/smtpserver"


' Set the mail server configuration
Set objConfig = Server.CreateObject("CDO.Configuration")
objConfig.Fields.Item(sendUrl)=2 ' cdoSendUsingPort
objConfig.Fields.Item(smtpUrl)="relay-hosting.secureserver.net"
objConfig.Fields.Update


CompanyName = Request.Form("CompName")
PostalAddress = Request.Form("postalAdd")
City = Request.Form("City")

emsg = "Company Name: " & CompanyName & VbCrLf & _
"Postal Address: " & PostalAddress & VbCrLf & _
"City: " & City & VbCrLf


' Create and send the mail
Set objMail = Server.CreateObject("CDO.Message")
' Use the config object created above
Set objMail.Configuration=objConfig
objMail.From="website@trimarforwarding.com"
objMail.ReplyTo="sender@coolexample.com"
objMail.To="m.amer@trimarforwarding.com"
objMail.Subject="subject"
objMail.TextBody= emsg
objMail.Send()

Server.Transfer("http://www.trimarforwarding.com/11.htm")
End If
%>

Old Pedant
12-14-2009, 07:46 PM
FP has *really* messed up that page!

It has *TWO* <form> tags!!!!

NESTED inside each other!

ILLEGAL HTML!

I think you need to just remove the FP stuff.

And follow Miranda's advice. But put that code she shows *ABOVE* the <body> tag of your page. Because she is doing a Server.Transfer (good) but you don't want the <form> stuff to be re-displayed if you do the transfer.

Mamdouh AMer
12-21-2009, 12:53 PM
thanks all for all of this information,

but it still not working i don't know way...

can any one end to my this page.... because i'm not able to finish it...

so i hope anyone finish it for my....

and bythey way every time i refesh the page i get the Same empty mail, in the same time the page don't redirect after i press sumbet it still in the same page without any redirect for the other htm page which i conected with...

vinyl-junkie
12-22-2009, 02:24 AM
Go into code view of FrontPage and hand-code this. Otherwise, FrontPage will continue to screw it up! Replace you code with one of the working examples you've been given in this thread. Change variable values to match your "from" and "to" email addresses, mail server name, subject and body of the email. Problem solved!

If you'd rather have someone do this for you rather than figuring it out on your own, please post your request in the appropriate Web Projects forum (http://www.codingforums.com/forumdisplay.php?f=47).

Mamdouh AMer
01-04-2010, 11:48 AM
thanks for your post,

i end my page and it working so great but i still not able to redirect the page when i press submit buttom...!!! even i cheked the hyberlink and it already in...

how i can redirect the page while when i press submit buttom........ help in that plzzz..

Mamdouh AMer
01-06-2010, 09:59 AM
So, i think its just order in the bottom after the CDO code in order to redirect to HTML thanks page or whatever it will go to .... so please what is this ASP order ...

Old Pedant
01-06-2010, 07:24 PM
Response.Redirect "thanks.html"

OR

Response.Redirect "thanks.asp"

OR

Server.Transfer "thanks.asp"

You can only Server.Transfer to another ASP page, and the effect is a little different than using Response.Redirect. So try both.

Mamdouh AMer
01-09-2010, 06:30 PM
thanks so much its working very well

thanks alot of thanks about your help