Convert html page or database shopping basket to an email

R

Richard Pain

OK - I have a shopping basket with data in a database. Once the person
has successfully completed their order I want to be able to send them
an email with the products ordered roughly in the following format:

Product Price Quantity

prod1 £6.99 1
prod2 £5.99 2
Postage £0.50

Total whatever..I'm
lazy

Formatting would be a little different (just spacing out the prod
table a little more.

Any ideas or links to scripts that do this?. I've been looking for a
while now but have had no luck in finding a solution. I just want to
send a text email (and not html).

The other thing is that on the last page but one, this shopping basket
is displayed. Is there anyway I could capture the html data from that
page, store it in a session variable and then generate the email after
the order has been completed (so sort of like sending a mirror of that
page)? In that case having a HTML formatted email would be ok.


Many thanks,

Richard Pain
 
D

Dominique

My Solution has always been to create a UDF to which i can send parameters,
which in turn generates the HTML email and sends it.

In your case, you can just query the data in your hopping basket, and have
it spit out the rows containing the data you have below.

Mail me if you want an example of what i'm talking about

Laterz
Dominique
 
R

Richard Pain

Hmmm - unfortunately I'm using mysql (hosting on linux with chilliasp)

Thanks

Richard
 
R

Roland Hall

in message
: OK - I have a shopping basket with data in a database. Once the person
: has successfully completed their order I want to be able to send them
: an email with the products ordered roughly in the following format:
:
: Product Price Quantity
:
: prod1 £6.99 1
: prod2 £5.99 2
: Postage £0.50
:
: Total whatever..I'm
: lazy
:
: Formatting would be a little different (just spacing out the prod
: table a little more.
:
: Any ideas or links to scripts that do this?. I've been looking for a
: while now but have had no luck in finding a solution. I just want to
: send a text email (and not html).
:
: The other thing is that on the last page but one, this shopping basket
: is displayed. Is there anyway I could capture the html data from that
: page, store it in a session variable and then generate the email after
: the order has been completed (so sort of like sending a mirror of that
: page)? In that case having a HTML formatted email would be ok.

Richard...

How are you sending the email, Sendmail?

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
R

Roland Hall

in message : I think it's just 'mail' - the syntax is:
:
: mail($to, $subject, $body);

Richard...

This is PHP.
 
R

Richard Pain

Sorry - they've stuck with aspmail after all so the question is still
relevant to this post.

Thanks,

Richard
 
R

Roland Hall

in message : Sorry - they've stuck with aspmail after all so the question is still
: relevant to this post.

Ok, well to make sure you have the right one, there are two that are similar
in name.

ServerObjects ASPMail - http://www.serverobjects.com/products.htm#aspmail
Persits ASPEmail - http://www.aspemail.com/

If you're not referring to either of these, which server OS is this running
on?

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
R

Richard Pain

It is asp mail. In the end the gits didn't tell me that a page to do
this had already been written with text formatting and everything. I've
attached it below to help anyone else who may have the same problem as
me..


<%
if (Session("LoggedIn")<>"yes") then
response.redirect "adminlogin.htm"
end if

response.expires=-1000

function GetCountry(sCountryCode)
if (sCountryCode="040") then
GetCountry = "Austria"
elseif (sCountryCode="056") then
GetCountry = "Belgium"
elseif (sCountryCode="208") then
GetCountry = "Denmark"
elseif (sCountryCode="246") then
GetCountry = "Finland"
elseif (sCountryCode="250") then
GetCountry = "France"
elseif (sCountryCode="276") then
GetCountry = "Germany"
elseif (sCountryCode="528") then
GetCountry = "Holland (The Netherlands)"
elseif (sCountryCode="372") then
GetCountry = "Ireland"
elseif (sCountryCode="380") then
GetCountry = "Italy"
elseif (sCountryCode="442") then
GetCountry = "Luxembourg"
elseif (sCountryCode="578") then
GetCountry = "Norway"
elseif (sCountryCode="724") then
GetCountry = "Spain"
elseif (sCountryCode="752") then
GetCountry = "Sweden"
elseif (sCountryCode="756") then
GetCountry = "Switzerland"
elseif (sCountryCode="826") then
GetCountry = "United Kingdom"
end if
end function

sOID = request.querystring("OID")
set cnDB=server.createobject("adodb.connection")
set rsDB=server.createobject("adodb.recordset")
set rsDB2=server.createobject("adodb.recordset")
cnDB.open "etc", "etc", "etc"
sSQL="UPDATE Orders SET transactionstatus='Confirmed' WHERE OID=" & sOID
cnDB.execute sSQL

sSQL="SELECT * FROM Orders WHERE OID=" & sOID
rsDB.open sSQL, cnDB
if (rsDB.EOF=false) then

sbody = "Please do not reply to this email" & vbCrLf & vbCrLf
sbody = sbody & "Thank you for ordering online at blah" & vbCrLf &
vbCrLf
sbody = sbody & "Below is a copy of your order. If you have any
queries regarding your order please contact us using any of the contact
means listed on our website." & vbCrLf & vbCrLf
sbody = sbody & "Your Details" & vbCrLf
sbody = sbody & "------------" & vbCrLf & vbCrLf
sbody = sbody & "Firstname " & rsDB("firstname") & vbCrLf
sbody = sbody & "Surname " & rsDB("surname") & vbCrLf
sbody = sbody & "Address " & rsDB("baddr1") & vbCrLf
if (rsDB("baddr2")<>"") then
sbody = sbody & " " & rsDB("baddr2") & vbCrLf
end if
if (rsDB("baddr3")<>"") then
sbody = sbody & " " & rsDB("baddr3") & vbCrLf
end if
sbody = sbody & " " & rsDB("bcity") & vbCrLf
sbody = sbody & " " & rsDB("bcountyprovince") & vbCrLf
sbody = sbody & " " & GetCountry(rsDB("bcountry")) &
vbCrLf
sbody = sbody & "Postcode " & rsDB("bpostalcode") & vbCrLf
sbody = sbody & "Telephone " & rsDB("btelephonenumber") & vbCrLf
sbody = sbody & "Email " & rsDB("email") & vbCrLf & vbCrLf

sbody = sbody & "Your Order" & vbCrLf
sbody = sbody & "----------" & vbCrLf
sbody = sbody & "Invoice E" & sOID & vbCrLf
sbody = sbody & "Date " & rsDB("EntryDate") & vbCrLf & vbCrLf
sbody = sbody & "Del. Address " & rsDB("saddr1") & vbCrLf
if (rsDB("saddr2")<>"") then
sbody = sbody & " " & rsDB("saddr2") & vbCrLf
end if
if (rsDB("saddr3")<>"") then
sbody = sbody & " " & rsDB("saddr3") & vbCrLf
end if
sbody = sbody & " " & rsDB("scity") & vbCrLf
sbody = sbody & " " & rsDB("scountyprovince") & vbCrLf
sbody = sbody & " " & GetCountry(rsDB("scountry")) &
vbCrLf
sbody = sbody & "Postcode " & rsDB("spostalcode") & vbCrLf
sbody = sbody & "Telephone " & rsDB("stelephonenumber") & vbCrLf &
vbCrLf

sbody = sbody & "Product Price Quantity
Total Price" & vbCrLf
sbody = sbody &
"---------------------------------------------------------------" &
vbCrLf

dTotalPrice=0.0

sSQL = "SELECT * FROM ShoppingBasket WHERE BasketID=" & sOID & " ORDER
BY EntryDate DESC;"
rsDB2.open sSQL, cnDB
do while (rsDB2.EOF=false)
sbody = sbody & left(rsDB2("ProductName") & " - " & rsDB2("SubCode")
& " ", 30)
sbody = sbody & right(" " & FormatCurrency(rsDB2("Price")),
10) & right(" " & rsDB2("Quantity"), 8)
sbody = sbody & right (" " &
FormatCurrency(rsDB2("Price") * rsDB2("Quantity")), 15) & vbCrLf
dTotalPrice=dTotalPrice + (rsDB2("Price") * rsDB2("Quantity"))
rsDB2.MoveNext
loop
rsDB2.close
sbody = sbody &
"---------------------------------------------------------------" &
vbCrLf
sbody = sbody & " Nett Total
" & right(" " & FormatCurrency(dTotalPrice), 10) & vbCrLf
sbody = sbody & " Carriage
" & right(" £" & rsDB("delivery"), 10) & vbCrLf
sbody = sbody & " VAT
" & right(" £" & rsDB("vat"), 10) & vbCrLf
sbody = sbody & " Total
" & right(" £" & rsDB("total"), 10) & vbCrLf & vbCrLf & vbCrLf
sbody = sbody & "This email does not constitute an order until payment
has been received." & vbCrLf & vbCrLf

Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName = "blah"
Mailer.FromAddress= "blah"
Mailer.RemoteHost = "blah"
Mailer.AddRecipient rsDB("firstname") & " " & rsDB("surname"),
rsDB("email")
Mailer.Subject = "product order"
Mailer.BodyText = sBody
Mailer.SendMail
Set Mailer = Nothing

end if
rsDB.close
set rsDB=Nothing
set rsDB2=Nothing

cnDB.close
set cnDB=nothing
response.redirect "adminorders.asp"
%>


Many thanks for your interest,

Richard
 
R

Roland Hall

in message
: It is asp mail. In the end the gits didn't tell me that a page to do
: this had already been written with text formatting and everything. I've
: attached it below to help anyone else who may have the same problem as
: me..
:

Ah, regular ASP mail.

I'm not sure what a git is but it doesn't sound good. (O:=
Thanks for responding with the solution Richard.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 

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,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top