Click to See Complete Forum and Search --> : Problem automating sending web page in email


GavinStollar
05-09-2005, 03:56 AM
:confused:

Hi i am battling to find a solution to two problems. I am not the best programmer in the world as well which makes things more difficult. I have designed an Ecommerce products section for my website. I have used Access 2003 and Front page 2003.I have managed to complete 95% of the functionality for the eCommerce section i.e. u can add stuff to basket, delete, update it etc. The basket keeps track of what you have ordered. You can then commit the order, enter your customer info and an invoice page pops up. The invoice page simply displays three database results sections 1) customer info 2) order detail committed 3) order totals committed. I have received a mail.asp file from my service provide that lets me submit info into a text field and email it via there mail server. I have looked at solutions all over the web and most of them appear to deal with information submitted into a form being emailed, not information being displayed on a web page via database results , being emailed



My questions are:



1) What is the easiest way for me to automatically (when a button is clicked by the visitor) to send the invoice as it looks on the web page to the customer & me who just placed the order in html format?





2) When a visitor enters the basket section of the application he has to press on a button “click to view basket”. The submit button posts the users IP address back to the form. Below is the code:



<form BOTID="0" METHOD="POST" action="ProducsTotalBasket.asp">

<table BORDER="0" id="table55">

<tr>

<td>

<p style="line-height: 100%; margin-top: 0; margin-bottom: 0">

<input type="image" value="Submit" border="0" id="img14" src="images/button8A1.jpg" height="20" width="155" alt="Click to View your Basket" fp-style="fp-btn: Glass Rectangle 5; fp-font-color-hover: #0000FF; fp-font-color-press: #FF0000; fp-proportional: 0; fp-orig: 0" fp-title="Click to View your Basket" onmouseover="FP_swapImg(1,0,/*id*/'img14',/*url*/'images/button8B1.jpg')" onmouseout="FP_swapImg(0,0,/*id*/'img14',/*url*/'images/button8A1.jpg')" onmousedown="FP_swapImg(1,0,/*id*/'img14',/*url*/'images/button8C1.jpg')" onmouseup="FP_swapImg(0,0,/*id*/'img14',/*url*/'images/button8B1.jpg')" <img name="I1"></td>

<td>



<p style="line-height: 100%; margin-top: 0; margin-bottom: 0">



<input TYPE="HIDDEN" NAME="Remote_computer_name" VALUE="<%=Request.Servervariables("REMOTE_ADDR")%>" size="20">

</tr>

</table>

</form>





I have tried to automate the submit function by placing the following code into the body of the web page:



<BODY onLoad="window.document.postform.submit()">



This works, in that the records in the basket are displayed automatically without clicking on the submit button however the screen starts going berserk and the form keeps posting to itself i.e. the “ProducsTotalBasket.asp” page mentioned above. It simply won’t stop & keeps looping and posting over and over again.



Please help me?

simflex
05-09-2005, 12:24 PM
Let me answer your questions in reverse.

You should design your ecommerce in such each time a customer adds item to a basket, he or she is taken automatically to view basket.

While on this page, they will see what product(s) they have added to their baskets, quantity, unit prize, total prize *And* they have the opportunity (option) of recalculating their products by either increasing the quantity, reducing it or deleting it entirely.
And if they are satisfied with their order, they should have the option of proceeding to checkout; if they need to continue shopping, they should have the option of going back to order more stuff.

All of these should be done in *one* asp file.

The meat of what I am saying is this snip:

If prodid <> "" Then
call addToCart()
Else
Dim strAction
strAction = UCase(Left(Request.Form("action"),5))
Select Case strAction
Case "CONTINUE" 'continue shopping
Response.Redirect "home.asp"
Case "RECAL" 'recalculate
call recalculateCart()
Case "PROCEED" 'proceed to checkout
Response.Redirect "checkout.asp"
End Select
'end if for updating or inserting new item in Cart
End If


Now your first question, it is a very trivial solution:

Add the products to the db.
Once the products are added, pick them (or most of them) up from the db, define form variables, pass those variables to your email component, and incorporate your submit button so that once they click submit, they will receive and email, and so will you.

You can hardcode your email info in the form but their info should be dynamically generated from the db, probably the db that contains customer contact info.

something like this will suffice:

emailDB.Execute "INSERT INTO emails (fields)" & _
"values" & _
"(form variables)"

then retrieve them:
'ok record in, now retrieve the primary key

sql = "SELECT * FROM emails where certain conditions apply"
'Response.write SQL 'always do this or you have yourself to blame
'Response.end
set rs = emaildb.execute(sql)

now define some form variables:

if not rs.EOF then

form variable = rs("db fied")

etc

Then time to send email

depending on what email component your server allows, then pass those form variables and vavoom!!

Let me know if we are on the right track for you.

GavinStollar
05-10-2005, 11:56 AM
thanks for the hlep will give it a try

wmif
05-10-2005, 04:40 PM
check out the ".CreateMHTMLBody " property of cdo.message.

http://www.w3schools.com/asp/asp_send_email.asp

lets you create a page using a gui and basically attach it into the email.

buntine
05-10-2005, 09:38 PM
Excellent post, Simflex.

GavinStollar
05-13-2005, 12:30 PM
Thanks for the link to http://www.w3schools.com/asp/asp_send_email.asp as I was not aware of the “.CreateMHTMLBody " property of a cdo.message. However, despite being a great piece of code it does not help me. The code appears to only work for static web page content not dynamic content i.e. based on what the user selected. The HTML page sent is not what is currently on the screen but the default web page prior to the user making his selection

wmif
05-13-2005, 01:38 PM
ive used it to email asp generated pages. you need to have the user make the selection and pass some variables to this page and have asp do its magic.

simflex
05-16-2005, 10:39 PM
and explain what you expect to accomplish with the email component.

We should be able to assist you to get it to work.

GavinStollar
05-17-2005, 01:00 PM
Hi,

I managed to get the code “.CreateMHTMLBody " property of a cdo.message. to work however a blank page was returned, reason being the web page reflects what a customer has ordered based on his IP address. When the CreateMHTMLBody property is triggered the web page has no idea what the current users IP address is.

I found some code on the web which passes variables together with the CreateMHTMLBody property.

.CreateMHTMLBody "http://www.usautobarn.com/test/email.asp?OrderID=" & OrderID & "&CustomerID=" & CustomerID

However I am not sure how to apply it to fit my scenario and pass the "&Request.Servervariables("REMOTE_ADDR")&" value .

Below is an example of the SQL code that runs on the page to display open orders based on the users IP address.


The SQL statemtn is <%
fp_sQry="SELECT * FROM productOrderTotals WHERE (Remote_computer_name = '"&Request.Servervariables("REMOTE_ADDR")&"')"

fp_sDefault="Remote_computer_name="
fp_sNoRecords="<tr><td colspan=7 align=""LEFT"" width=""100%""> </td></tr>"
fp_sDataConn="DigitalLifestyle"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=5
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice="TotalPriceInclusiveofVAt"
fp_sMenuValue="TotalPriceInclusiveofVAt"
fp_sColTypes="&TotalPriceInclusiveofVAt=5&Shipping=3&NoShipping=3&TotalPriceInclusiveofVAtShipping=5&VATportioninclshipping=5&VATportioninnoshipping=5&Total no Shipping=5&Remote_computer_name=202&Committed=202&Deleted=202&"
fp_iDisplayCols=7
fp_fCustomQuery=False
BOTID=1
fp_iRegion=BOTID
%>.CreateMHTMLBody "http://www.usautobarn.com/test/email.asp?OrderID=" & OrderID & "&CustomerID=" & CustomerID

Please advise how to pass the IP address variable so that the web page returns with the user purchase order and not a blank page.

wmif
05-17-2005, 02:57 PM
i think you should consider the ip value. users could have a different ip address each time they visit your page. this would allow other users to view other users orders because they might have picked up this ip address.