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

sending HTML mail with CDONTS 2

Status
Not open for further replies.

cantona

Technical User
May 20, 2001
121
GB
Can anyone help!

I am trying to send the contents of an access database table in the body of an email using CDONTS. However, when the email is sent only the first row of the db table is displayed. how do i move to the next record? so the table contains all the relevant records?

this is what i have been trying;


sqlString = "SELECT order_id, FROM etc...

emailRS.Open sqlString


%>
<%
Dim sMailBody

Set NewMailObj = CreateObject (&quot;CDONTS.NewMail&quot;)
NewMailObj.From = &quot;blah blah.com&quot;
NewMailObj.To = &quot;anyone&quot;
NewMailObj.Subject = &quot;New Order Received!&quot;
NewMailObj.BodyFormat = CdoBodyFormatHTML
NewMailObj.MailFormat = CdoMailFormatMime
sMailBody = sMailBody & &quot;<HTML><HEAD><TITLE>New order</TITLE></HEAD>&quot;
sMailBody = sMailBody & &quot;<BODY><TABLE width=&quot;&quot;600&quot;&quot; border=&quot;&quot;1&quot;&quot; cellpadding=&quot;&quot;4&quot;&quot; cellspacing=&quot;&quot;0&quot;&quot;>&quot;
sMailBody = sMailBody & &quot;<TR><TH>Product</TH><TH>Description</TH><TH>Quantity</TH><TH>Price</TH><TH>Order Date</TH></TR>&quot;
sMailBody = sMailBody & &quot;<tr><td>&quot; & emailRS(&quot;product_partnumber&quot;) & &quot;</td>&quot;
sMailBody = sMailBody & &quot;<td>&quot; & emailRS(&quot;product_briefdesc&quot;) & &quot;</td>&quot;
sMailBody = sMailBody & &quot;<td>&quot; & emailRS(&quot;order_quantity&quot;) & &quot;</td>&quot;
sMailBody = sMailBody & &quot;<td>&quot; & emailRS(&quot;product_price&quot;) & &quot;</td>&quot;
sMailBody = sMailBody & &quot;<td>&quot; & emailRS(&quot;order_entrydate&quot;) & &quot;</td>&quot;
sMailBody = sMailBody & &quot;</table>&quot;
NewMailObj.Body = sMailBody
NewMailObj.Send

When this is run, the email is delivered oK, but only contains the first row of products. if more than one product has been ordered, they are missing.

hope someone can help!!
 
sMailBody = sMailBody & &quot;<TR><TH>Product</TH><TH>Description</TH><TH>Quantity</TH><TH>Price</TH><TH>Order Date</TH></TR>&quot;

while not emailRS.eof
sMailBody = sMailBody & &quot;<tr><td>&quot; & emailRS(&quot;product_partnumber&quot;) & &quot;</td>&quot;
sMailBody = sMailBody & &quot;<td>&quot; & emailRS(&quot;product_briefdesc&quot;) & &quot;</td>&quot;
sMailBody = sMailBody & &quot;<td>&quot; & emailRS(&quot;order_quantity&quot;) & &quot;</td>&quot;
sMailBody = sMailBody & &quot;<td>&quot; & emailRS(&quot;product_price&quot;) & &quot;</td>&quot;
sMailBody = sMailBody & &quot;<td>&quot; & emailRS(&quot;order_entrydate&quot;) & &quot;</td></tr>&quot;
emailRS.movenext
wend

sMailBody = sMailBody & &quot;</table>&quot;
NewMailObj.Body = sMailBody
NewMailObj.Send


something along those lines.

:)
Paul Prewett
 
If you had more than one record in your recordset, wouldn't you loop through your recordset like this?

<%
sMailBody = sMailBody & &quot;<HTML><HEAD><TITLE>New order</TITLE></HEAD>&quot;
sMailBody = sMailBody & &quot;<BODY><TABLE width=&quot;&quot;600&quot;&quot; border=&quot;&quot;1&quot;&quot; cellpadding=&quot;&quot;4&quot;&quot; cellspacing=&quot;&quot;0&quot;&quot;>&quot;
sMailBody = sMailBody & &quot;<TR><TH>Product</TH><TH>Description</TH><TH>Quantity</TH><TH>Price</TH><TH>Order Date</TH></TR>&quot;
do while not emailRS.EOF
sMailBody = sMailBody & &quot;<tr><td>&quot; & emailRS(&quot;product_partnumber&quot;) & &quot;</td>&quot;
sMailBody = sMailBody & &quot;<td>&quot; & emailRS(&quot;product_briefdesc&quot;) & &quot;</td>&quot;
sMailBody = sMailBody & &quot;<td>&quot; & emailRS(&quot;order_quantity&quot;) & &quot;</td>&quot;
sMailBody = sMailBody & &quot;<td>&quot; & emailRS(&quot;product_price&quot;) & &quot;</td>&quot;
sMailBody = sMailBody & &quot;<td>&quot; & emailRS(&quot;order_entrydate&quot;) & &quot;</td>&quot;
sMailBody = sMailBody & &quot;</tr>&quot;
emailRS.MoveNext
loop
sMailBody = sMailBody & &quot;</table>&quot;
%>
 
Thank you for your help Link9 & Gamera99,

Both offerings, work perfectly well

easy when you know how eh!!

regards,

Cantona
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top