asp looping i presume

bitsnz

Fledgling Freddie
Joined
Mar 16, 2004
Messages
3
I have a website that takes in user details and sends an html body email to confirm their details. The details they enter are in regard to boat travelling. They are able to take a vehicle if they wish. Im having a problem with users entering multiple people going on a trip and taking multiple cars with them. If it was one person with no car, its easy to email an html body email but when they have more than one person taking more then one car then im stuck because i dont know the code to use. what do i do to enable multiple data to appear in an html body email?

is there sample code somewhere?

cheers all
 

Xavier

Can't get enough of FH
Joined
Dec 22, 2003
Messages
1,542
Best thing to do is paste your code here using the
Code:
 tags and let us see how far you've gotten.
 
 Xav
 

Xavier

Can't get enough of FH
Joined
Dec 22, 2003
Messages
1,542
Incidetally, it just sounds like you need to build a conditional statement before writing out the email, maybe using a SELECT CASE. But as I said, paste your page code here, with a full explanation as to what you're trying to achieve and I'll see if I can help.

Xav
 

bitsnz

Fledgling Freddie
Joined
Mar 16, 2004
Messages
3
Cheers for the help xavier.

At the moment i have the confirmation set out in text form (see below). The code works brilliantly and multiple people or vehicles travelling is registered and shown in the confirmation.
I have a html template that is more prefered rather than the text format, but I dont know the code to use to register multiple people and vehicles.
The html code has flags in which i search for and replace them with the appropriate user detail. Single entities of a person and vehicle is no problem as it searches for the particular detail and swaps it, but i cant for the life of me work out how to do this if there are multiple people and multiple vehicles as im using only one flag for each user detail not multiple flags. I know i could add multiple flags for each extra person or vehicle but how many do i add, theoretically 15 people could bring 50 vehicles, therefore do i account for this and add in 15 extra people flags and 50 vehicle flags???? i think not!

I presume its a loop of some sort that i have to use but i cant figure it out.

Like i said previously, below is the text format code. I'll follow this post with another showing the html template that i want to use for the confirmation.
by the way...the flags used are in belgian..but its not important to know what they mean and the flags are expressed as #(flag)#

Code:
<%
Dim objCurrNode
Dim objDom
Dim objField
Dim objFieldValue
Dim objattID
Dim objattTabOrder
Dim objPI
Dim x
Dim y
Dim nrtravelers
Dim nrcars 

Set objDom = server.CreateObject("Microsoft.XMLDOM")

xmlFile	= Request.Form("orderID") 

objDom.async = False
objDom.load(Server.MapPath("..\Polis\waiting\" &  xmlFile & ".xml"))


Dim Attr, Text 

Dim emailaddress, touroperator, reisbestemming, kostprijs
Dim sexcontact, naamcontact, straat, gemeente, telefoon
Dim vertrdd, vertrmm, vertrjj
Dim retdd, retmm, retjj
Dim bookdd, bookmm, bookjj
Dim objAttributes, objRefAttr

dim mypolisNr 
dim travelerNaam
dim traveleryear
dim travelerday
dim travelermonth
dim travelersex
dim travelermakeofcar
dim travelermonthofreg
dim traveleryearofreg
dim travelerplatereg


objDom.preserveWhiteSpace = True
 
Set objCurrNode = objDom.documentElement.lastChild 

Set objAttributes = objCurrNode.attributes 

Set objRefAttr = objAttributes.getNamedItem("email")
emailaddress = objRefAttr.nodeValue

Set objRefAttr = objAttributes.getNamedItem("reizigersveld")
nrtravelers = objRefAttr.nodeValue

Set objRefAttr = objAttributes.getNamedItem("voertuigenveld")
nrcars = objRefAttr.nodeValue

Set objRefAttr = objAttributes.getNamedItem("touroperator")
touroperator = objRefAttr.nodeValue

Set objRefAttr = objAttributes.getNamedItem("reisbestemming")
reisbestemming = objRefAttr.nodeValue

Set objRefAttr = objAttributes.getNamedItem("kostprijs")
kostprijs = objRefAttr.nodeValue

Set objRefAttr = objAttributes.getNamedItem("sexcontact")
sexcontact = objRefAttr.nodeValue

Set objRefAttr = objAttributes.getNamedItem("naamcontact")
naamcontact = objRefAttr.nodeValue

Set objRefAttr = objAttributes.getNamedItem("straat")
straat = objRefAttr.nodeValue

Set objRefAttr = objAttributes.getNamedItem("gemeente")
gemeente = objRefAttr.nodeValue

Set objRefAttr = objAttributes.getNamedItem("telefoon")
telefoon = objRefAttr.nodeValue

Dim Mailer
Dim sMailbody
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.Fromname = "Artas Website"
Mailer.fromaddress = "info@artas.be"
Mailer.remotehost = "smtp.easynet.be"
Mailer.addrecipient "Artas ", "info@artas.be"
Mailer.addrecipient "Klient", emailaddress
Mailer.Subject = "Artas Online Booking Polis : " &  xmlFile
sMailbody =             "Artas Online Booking Polis : " &  xmlFile  & vbnewline
sMailbody = sMailbody & "Uw Email addres            : " & emailaddress  & vbnewline
sMailbody = sMailbody & "aantal reizigers           : " & nrtravelers  & vbnewline
sMailbody = sMailbody & "aantal voertuigen          : " & nrcars  & vbnewline

sMailbody = sMailbody & vbnewline
sMailbody = sMailbody & "**************** Details reizigers ****$$$$$$$$****************"  & vbnewline

For x = 1 To nrtravelers
Set objRefAttr = objAttributes.getNamedItem("reiziger" & x)
    travelerNaam = objRefAttr.nodeValue
Set objRefAttr = objAttributes.getNamedItem("manvrouw" & x)
    travelersex = objRefAttr.nodeValue
Set objRefAttr = objAttributes.getNamedItem("geboortedag" & x)
    travelerday = objRefAttr.nodeValue
Set objRefAttr = objAttributes.getNamedItem("geboortemaand" & x)
    travelermonth = objRefAttr.nodeValue
Set objRefAttr = objAttributes.getNamedItem("geboortejaar" & x)
    traveleryear = objRefAttr.nodeValue

sMailbody = sMailbody & x & vbtab & "Naam" & " - " & travelerNaam & vbCrlf 
sMailbody = sMailbody & "" & vbtab & "Geslacht" &  " - " & travelersex & vbCrlf
sMailbody = sMailbody & "" & vbtab & "Geboortedatum reiziger " & " - " & travelerday & "/" & travelermonth & "/" & traveleryear & vbnewline

Next

sMailbody = sMailbody & vbnewline
sMailbody = sMailbody & "**************** Details voertuigen reiziger ******************"  & vbnewline

For y = 1 To nrcars
Set objRefAttr = objAttributes.getNamedItem("makeofcar" & y)
    travelermakeofcar = objRefAttr.nodeValue
Set objRefAttr = objAttributes.getNamedItem("monthofreg" & y)
    travelermonthofreg = objRefAttr.nodeValue
Set objRefAttr = objAttributes.getNamedItem("yearofreg" & y)
    traveleryearofreg= objRefAttr.nodeValue
Set objRefAttr = objAttributes.getNamedItem("plateofreg" & y)
    travelerplatereg = objRefAttr.nodeValue

sMailbody = sMailbody & y & vbtab & "Merk auto" & " - " & travelermakeofcar & vbCrlf 
sMailbody = sMailbody & "" & vbtab & "Jaar inschrijving voertuig" &  " - " & travelermonthofreg & "/" & traveleryearofreg & vbCrlf
sMailbody = sMailbody & "" & vbtab & "Plaat voertuig" & " - " & travelerplatereg & vbnewline

Next

sMailbody = sMailbody & vbnewline
sMailbody = sMailbody & "**************** Contactpersoon *******************************"  & vbnewline
sMailbody = sMailbody & "**************** Details reis *********************************"  & vbnewline

sMailbody = sMailbody & "Aanspreektitel : " & sexcontact & vbnewline
sMailbody = sMailbody & "Naam           : " & naamcontact & vbnewline
sMailbody = sMailbody & "straat         : " & straat & vbnewline
sMailbody = sMailbody & "gemeente       : " & gemeente & vbnewline
sMailbody = sMailbody & "telefoon       : " & telefoon & vbnewline

sMailbody = sMailbody & vbnewline
sMailbody = sMailbody & "**************** Details reis *********************************"  & vbnewline

Set objRefAttr = objAttributes.getNamedItem("vertrdd")
    vertrdd = objRefAttr.nodeValue
Set objRefAttr = objAttributes.getNamedItem("vertrmm")
    vertrmm = objRefAttr.nodeValue
Set objRefAttr = objAttributes.getNamedItem("vertrjj")
    vertrjj = objRefAttr.nodeValue

Set objRefAttr = objAttributes.getNamedItem("retdd")
    retdd = objRefAttr.nodeValue
Set objRefAttr = objAttributes.getNamedItem("retmm")
    retmm = objRefAttr.nodeValue
Set objRefAttr = objAttributes.getNamedItem("retjj")
    retjj = objRefAttr.nodeValue

Set objRefAttr = objAttributes.getNamedItem("bookdd")
    bookdd = objRefAttr.nodeValue
Set objRefAttr = objAttributes.getNamedItem("bookmm")
    bookmm = objRefAttr.nodeValue
Set objRefAttr = objAttributes.getNamedItem("bookjj")
    bookjj = objRefAttr.nodeValue

sMailbody = sMailbody & "Vertrekdatum      : " &  vertrdd & "/" & vertrmm & "/" & vertrjj & vbnewline
sMailbody = sMailbody & "Retourdatum       : " &  retdd & "/" & retmm & "/" & retjj & vbnewline
sMailbody = sMailbody & "Boekingsdatum     : " &  bookdd & "/" & bookmm & "/" & bookjj & vbnewline

sMailbody = sMailbody & "Touroperator      : " & touroperator & vbnewline
sMailbody = sMailbody & "Reisbestemming    : " & reisbestemming & vbnewline
sMailbody = sMailbody & "Reissom           : " & kostprijs & vbnewline

sMailbody = sMailbody & "***************************************************************"  & vbnewline

Mailer.Bodytext = sMailbody
Mailer.SendMail

Set Mailer = Nothing

For x = 1 To Request.Form.Count

 If instr(1,Request.Form.Key(x),"bereken") = 0 Then

	Set Attr = objDom.createAttribute(Request.Form.Key(x)) '
	Set Text = objDom.createTextNode(Request.Form(x)) 
	Attr.appendChild(Text) 
	
	objCurrNode.setAttributeNode(Attr) 

 End If
Next 
 
 objDom.save(Server.MapPath("..\Polis\accepted\" &  xmlFile &  ".xml"))
 
 Set objDom = Nothing
 Set objCurrNode = Nothing
 Set objField = Nothing
 Set objFieldValue = Nothing
 Set objattID = Nothing
 Set objattTabOrder = Nothing
 Set objPI = Nothing


%>
 

bitsnz

Fledgling Freddie
Joined
Mar 16, 2004
Messages
3
Hi xavier, ive had to cut a lot out of the code because it was excessive, but the basics are still there....cheers for the help


Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<FORM name=JadeForm action=http://:?Administration method=post><BASEFONT size=1>
<META content="MSHTML 6.00.2800.1141" name=GENERATOR></HEAD>
<BODY>
<BR>
<TABLE cellSpacing=0 cellPadding=0 width=683 border=0>
  <TBODY>
  <TR height=0>
    <TD width=34></TD>
    <TD width=1></TD>
    <TD width=632></TD>
    <TD width=1></TD>
    <TD width=15></TD></TR>
  <TR height=11>
    <TD></TD></TR>
  <TR>
    <TD></TD>
    <TD vAlign=top bgColor=#ffffff colSpan=2>
      <TABLE height=313 cellSpacing=0 cellPadding=0 rules=none width=633 
      bgColor=#ffffff border=0>
        <TBODY>
        <TR height=0>
          <TD width=4></TD>
          <TD width=4></TD></TR>
        <TR>
          <TD colSpan=25 height=2></TD></TR>
        <TR>
          <TD></TD>
          <TD vAlign=top bgColor=#ffffff colSpan=4 rowSpan=6><IMG height=39 
            alt="" hspace=0 
            src="http://www.artas.be/jadeEval/Images/picArtas.jpg" width=131 
            border=1></TD>
          <TD colSpan=20 height=1></TD></TR>
        <TR>
          <TD></TD>
          <TD colSpan=2></TD>
          <TD vAlign=middle noWrap align=left colSpan=9 rowSpan=3><FONT 
            face=Arial color=#000000 size=3><B>Email Confirmation of Polisnr : #polisNr#</B></FONT></TD>
          </TR>
        <TR>
          <TD></TD>
          <TD colSpan=2></TD>
          <TD vAlign=middle noWrap align=center><FONT face=Arial color=#000000 
            size=2>#date#</FONT></TD>
          <TD vAlign=middle noWrap align=center colSpan=4><FONT face=Arial 
            color=#000000 size=2>pagina's 1 / </FONT></TD>
          <TD colSpan=15 height=21></TD></TR>
        <TR>
          <TD></TD>
          <TD colSpan=2></TD>
          </TR>
        <TR>
          <TD></TD>
          <TD colSpan=24 height=6></TD></TR>
        <TR>
          <TD></TD>
          <TD colSpan=4></TD>
          <TD vAlign=top noWrap align=right colSpan=2 rowSpan=2>&nbsp;</TD>
          <TD colSpan=2></TD>
          <TD vAlign=top noWrap align=left colSpan=7 rowSpan=6>&nbsp;</TD>
          <TD colSpan=9 height=1></TD></TR>

...more html here

          <TD colSpan=25 height=4></TD></TR>
        <TR>
          <TD colSpan=2></TD>
          <TD vAlign=middle noWrap align=left colSpan=8><FONT face=Arial 
            color=#000000 size=3><B>Reisdata</B></FONT></TD>
          <TD colSpan=5></TD>
          <TD vAlign=middle noWrap align=left colSpan=3><FONT face=Arial 
            color=#000000 size=3><B>Polisdata</B></FONT></TD>
          <TD colSpan=7 height=20></TD></TR>
        <TR>
          <TD colSpan=25 height=4></TD></TR>
        <TR>
          <TD colSpan=3></TD>
          <TD vAlign=top noWrap align=left colSpan=11><FONT face=Arial 
            color=#000000 size=2>Reisdata van #Vertrekdatum# tot #Retourdatum# Duur : 
            1<BR>Bestemming : #bestemming#<BR>Touroperator : #touroperator#</FONT></TD>
          <TD></TD>
          <TD vAlign=top noWrap align=left colSpan=6><FONT face=Arial 
            color=#000000 size=2>Polisnr #polisNr#<BR>Uitgiftedatum : 
            27/03/2003<BR>Reservatiedatum : #reservatiedatum#<BR>Aantal personen : #aantalPersonen#
            </FONT></TD>
          <TD colSpan=4 height=62></TD></TR>
        <TR>
          <TD colSpan=25 height=7></TD></TR>
          
....more html here

height=440></TD></TR></TBODY></TABLE></FORM></BODY></BASEFONT></HTML>
 

Users who are viewing this thread

Top Bottom