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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looped recordset within CDONTS mail? 1

Status
Not open for further replies.

techskool

Technical User
Jun 20, 2002
151
GB
Im writing an order confirmation email to a customer who buys online.

The body part of the message which will confirm their address from the database is fine , cos there is only one instance of this, but when i try and add to the body the items ordered, i can only successfully write one item, with code form each field of the recordset.

If I try and put it in a loop to show all items the customer is buying, then the system falls down, and i assume this is because i am trying to read a loop into a variable for the body service of the new mail object.

How can i ensure a string of all variable amounts of items that are purchased, are written to a string?

Thanks

Dave

;-)


 
Can you post the body portion of the mailer script. I'm a bit confused on what is happening.

_________________________________________________________
$str = "sleep is good for you. sleep gives you the energy you need to function";
$Nstr = ereg_replace("sleep","coffee",$str); echo $Nstr;

onpnt2.gif
[/sub]
 
Heres the body variable i read into with the order details. There are 2 recordsets, one for address(rs), and one for items ordered (rs1):

eBody = "An order with postal payment has just been made." &vbcrlf&vbcrlf&_


"The customers details are as follows:" &vbcrlf&vbcrlf&_
"Customer :"&rs("Name") &vbcrlf&_
"Address :"&rs("Address") &vbcrlf&_
"Town :"&rs("Town ") &vbcrlf&_
"County :"&rs("County") &vbcrlf&_
"Country :"&rs("Country") &vbcrlf&_
"Postal Area :"&rs("Postal Area") &vbcrlf&_
"Postcode :"&rs("Postcode") &vbcrlf&_
"Phone No :"&rs("PhoneNo ") &vbcrlf&_
"Email :"&rs("Email") &vbcrlf&_

"The customers ORDER is as follows:" &vbcrlf&vbcrlf&_

Do While Not rs1.Bof And Not rs1.Eof &vbcrlf&_
rs1("IDref") &vbcrlf&_
rs1("Format") &vbcrlf&_
rs1("Artist") &vbcrlf&_
rs1("Title") &vbcrlf&_
rs1("YearMade") &vbcrlf&_
rs1("Price") &vbcrlf&_
rs1.movenext &vbcrlf&_
Loop &vbcrlf&_


"The customers has been notified to make payment,"&vbcrlf&_
"so please await a cheque or postal order"&vbcrlf&vbcrlf&_

"Thanks - Records North West Shopping Cart System"

I think i am reading in the items ordered wrong, reading in the code rather than the result of the code, if you get my meaning.

Thanks mate

Dave
 
ya, the loop will not work that way. this is pretty much a formatting of your code issue
first thing I wish they never added the _ carriage to vbscript as in VB. it drives me nuts.
instead of messing everything up with trying to add your loop into the building of the body take it out and concate the values together so the code is readable.

Do While Not rs1.Bof And Not rs1.Eof
eBody = eBody & vbcrlf & rs1("IDref") & vbcrlf
eBody = eBody & rs1("Format") & vbcrlf
eBody = eBody & rs1("Artist") & vbcrlf
eBody = eBody & rs1("Title") & vbcrlf
eBody = eBody & rs1("YearMade") & vbcrlf
eBody = eBody & rs1("Price") & vbcrlf
rs1.movenext
Loop
eBody = eBody & vbcrlf

_________________________________________________________
$str = "sleep is good for you. sleep gives you the energy you need to function";
$Nstr = ereg_replace("sleep","coffee",$str); echo $Nstr;

onpnt2.gif
[/sub]
 
Superb, .. and yes you are right about the _ carriage .

Do you know you must have written quarter of my website by now onpnt, m8. LOL

Dave

 
[lol]

just think how easy the next will be!

_________________________________________________________
$str = "sleep is good for you. sleep gives you the energy you need to function";
$Nstr = ereg_replace("sleep","coffee",$str); echo $Nstr;

onpnt2.gif
[/sub]
 
Heh heh , yes of course it will be, lol

onpnt, ive been testing this script.

an example of the body, when downloaded in Outlook / Outlook Express is:

Your order is as follows:

Stock No :918
Format :12"
Artist :Lee Marrow
Title :To Go Crazy
Year :1991
Price :£10.00

Stock No :655
Format :12"
Artist :Lee Marrow
Title :Movin And Pain
Year :1990
Price :£9.00


Sub Total :£19.00
Total inc P&P :£22.00


An example when viewed with AOL email is :

Your order is as follows:

Stock No :869
Format :12"
Artist :A Homeboy Hippie Funky Dredd
Title :Total Confusion
Year :1991
Price :0

Stock No :642
Format :12"
Artist :Anticappella
Title :Everyday
Year :1991
Price :00

Stock No :549
Format :12"
Artist :Blue Pearl
Title :Can You Feel The Passion
Year :1990
Price :00


Sub Total :00
Total inc P&P :00

Why is the price behaving in this way??

Is this a problem with the code, Vb script language, or is AOL just rubbish.

Thanks in advance

Dave
 
AOL and all mail components are going to read the mail differently. I have not coded for AOL before but I have heard of issues with it as well as otehrs like hotmail reading in values like the special characters differently and sometimes not at all.

are you sending this in rich text format or html format? I've stayed away from html format unless asked to code mailer scripts this way for this one reason. You also have to think of the people that do not view their mail in HTML. Then you may get a bunch of tags showing up in the mail making it non-readable.

for the fact that the values are coming out as 00.00. the only thing I can say without seeing the formatting of this value is the £ not being recognized in AOL may be setting this value that way.

_________________________________________________________
$str = "sleep is good for you. sleep gives you the energy you need to function";
$Nstr = ereg_replace("sleep","coffee",$str); echo $Nstr;

onpnt2.gif
[/sub]
 
Thanks for the quick reply onpnt.

Ive tested without the currency formating, just reading numerical data straight out of the recordset, to no avail.

Also im sending data in text format, theres no html.

I guess im just going to have to accept that its not going to work in AOL.

Thanks onpnt

Dave :)


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top