Forums
This topic is locked
Body mail in CDO
Posted 06 Sep 2001 13:52:38
1
has voted
06 Sep 2001 13:52:38 Folkert Jongbloed posted:
Is it poossible to place the results from a recordeset into the body of the mailobject? It's about sending multiple results from a result page to a mail adres. The results are dynamic. It could be just one result but it is also possible to see multiple results, placed into a repeat region. Is it possible to place some sort of code into the body of the mail so the results are all send in just one mail...Replies
Replied 07 Sep 2001 03:50:48
07 Sep 2001 03:50:48 Owen Eastwick replied:
Yes.
Place your table with the Results in within a form, then place a Hidden Field next to the dynamic text within each cell, its value being the same as the dynanmic text.
Use the Repeat Regions Loop behavior to rename the hidden field on each pass of the loop. So if you have a hidden field named MyField it will be Myfield1, MyField2 and so on.
Place the record count in another hidden field on the form.
set up a Submit button to Email the Results.
On the Email sending page set up another loop to get the contents of all the hidden fields, using the record count to calculate the number of loops you need to do.
Then set up yet another loop to place the the Fields into the mail body.
Is that enough to go on? Or do you need code?
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Place your table with the Results in within a form, then place a Hidden Field next to the dynamic text within each cell, its value being the same as the dynanmic text.
Use the Repeat Regions Loop behavior to rename the hidden field on each pass of the loop. So if you have a hidden field named MyField it will be Myfield1, MyField2 and so on.
Place the record count in another hidden field on the form.
set up a Submit button to Email the Results.
On the Email sending page set up another loop to get the contents of all the hidden fields, using the record count to calculate the number of loops you need to do.
Then set up yet another loop to place the the Fields into the mail body.
Is that enough to go on? Or do you need code?
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 10 Sep 2001 11:08:35
10 Sep 2001 11:08:35 Folkert Jongbloed replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Yes.
Place your table with the Results in within a form, then place a Hidden Field next to the dynamic text within each cell, its value being the same as the dynanmic text.
Use the Repeat Regions Loop behavior to rename the hidden field on each pass of the loop. So if you have a hidden field named MyField it will be Myfield1, MyField2 and so on.
Place the record count in another hidden field on the form.
set up a Submit button to Email the Results.
On the Email sending page set up another loop to get the contents of all the hidden fields, using the record count to calculate the number of loops you need to do.
Then set up yet another loop to place the the Fields into the mail body.
Is that enough to go on? Or do you need code?
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Yes.
Place your table with the Results in within a form, then place a Hidden Field next to the dynamic text within each cell, its value being the same as the dynanmic text.
Use the Repeat Regions Loop behavior to rename the hidden field on each pass of the loop. So if you have a hidden field named MyField it will be Myfield1, MyField2 and so on.
Place the record count in another hidden field on the form.
set up a Submit button to Email the Results.
On the Email sending page set up another loop to get the contents of all the hidden fields, using the record count to calculate the number of loops you need to do.
Then set up yet another loop to place the the Fields into the mail body.
Is that enough to go on? Or do you need code?
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Replied 10 Sep 2001 11:10:45
10 Sep 2001 11:10:45 Folkert Jongbloed replied:
If you do have some code for an example, please send it to me. Thanx for your respond, it really helped me allready....
Replied 10 Sep 2001 12:58:58
10 Sep 2001 12:58:58 Owen Eastwick replied:
Folkert,
Here is some code I worked on.
On the page displaying the records in a repeat region:
<pre id=code><font face=courier size=2 id=code>
<%
Counter1 = 1
Counter2 = 2
Counter3 = 3
%>
<% While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))%>
<tr bgcolor="#C7C7C7" valign="top">
<td width="50"><%=(Recordset1.Fields.Item("TextID".Value)%>
<input type="hidden" name="hiddenField<% = Counter1 %>" value="<%=(Recordset1.Fields.Item("TextID".Value)%>">
</td>
<td width="150"><%=(Recordset1.Fields.Item("ItemTitle".Value)%>
<input type="hidden" name="hiddenField<% = Counter2 %>" value="<%=(Recordset1.Fields.Item("ItemTitle".Value)%>">
</td>
<td width="500"><%=(Recordset1.Fields.Item("ItemText".Value)%>
<input type="hidden" name="hiddenField<% = Counter3 %>" value="<%=(Recordset1.Fields.Item("ItemText".Value)%>">
</td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset1.MoveNext()
Counter1 = Counter1 + 3
Counter2 = Counter2 + 3
Counter3 = Counter3 + 3
Wend </font id=code></pre id=code>
On the next page that actually sends the mail:
<pre id=code><font face=courier size=2 id=code>
<%@LANGUAGE="VBSCRIPT"%>
<%
'Collect the values from the hidden fields
MessageTo = Request("Email Address"
CountRecords = Request("CountRecords"
CountRecords = CInt(CountRecords)
RepeatRequest = 1
Counter1 = 1
Counter2 = 2
Counter3 = 3
MailBody = "ID | Title | Text" & vbCrLf
While RepeatRequest <= CountRecords
FirstField = Request("HiddenField"&Counter1)
SecondField = Request("HiddenField"&Counter2)
ThirdField = Request("HiddenField"&Counter3)
MailBody = MailBody & FirstField & " | " & SecondField & " | " & ThirdField & vbCrLf
Counter1 = Counter1 + 3
Counter2 = Counter2 + 3
Counter3 = Counter3 + 3
RepeatRequest = RepeatRequest + 1
Wend
'Create the mail object and send the mail
Dim objCDO
Set objCDO = Server.CreateObject("CDONTS.NewMail"
objCDO.To = MessageTo
objCDO.From = " "
objCDO.Subject = "Test Repeat Region Send"
objCDO.Body = MailBody
objCDO.Send
Set objCDO = Nothing
%>
</font id=code></pre id=code>
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Edited by - oeastwick on 09/10/2001 15:45:16
Here is some code I worked on.
On the page displaying the records in a repeat region:
<pre id=code><font face=courier size=2 id=code>
<%
Counter1 = 1
Counter2 = 2
Counter3 = 3
%>
<% While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))%>
<tr bgcolor="#C7C7C7" valign="top">
<td width="50"><%=(Recordset1.Fields.Item("TextID".Value)%>
<input type="hidden" name="hiddenField<% = Counter1 %>" value="<%=(Recordset1.Fields.Item("TextID".Value)%>">
</td>
<td width="150"><%=(Recordset1.Fields.Item("ItemTitle".Value)%>
<input type="hidden" name="hiddenField<% = Counter2 %>" value="<%=(Recordset1.Fields.Item("ItemTitle".Value)%>">
</td>
<td width="500"><%=(Recordset1.Fields.Item("ItemText".Value)%>
<input type="hidden" name="hiddenField<% = Counter3 %>" value="<%=(Recordset1.Fields.Item("ItemText".Value)%>">
</td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset1.MoveNext()
Counter1 = Counter1 + 3
Counter2 = Counter2 + 3
Counter3 = Counter3 + 3
Wend </font id=code></pre id=code>
On the next page that actually sends the mail:
<pre id=code><font face=courier size=2 id=code>
<%@LANGUAGE="VBSCRIPT"%>
<%
'Collect the values from the hidden fields
MessageTo = Request("Email Address"
CountRecords = Request("CountRecords"
CountRecords = CInt(CountRecords)
RepeatRequest = 1
Counter1 = 1
Counter2 = 2
Counter3 = 3
MailBody = "ID | Title | Text" & vbCrLf
While RepeatRequest <= CountRecords
FirstField = Request("HiddenField"&Counter1)
SecondField = Request("HiddenField"&Counter2)
ThirdField = Request("HiddenField"&Counter3)
MailBody = MailBody & FirstField & " | " & SecondField & " | " & ThirdField & vbCrLf
Counter1 = Counter1 + 3
Counter2 = Counter2 + 3
Counter3 = Counter3 + 3
RepeatRequest = RepeatRequest + 1
Wend
'Create the mail object and send the mail
Dim objCDO
Set objCDO = Server.CreateObject("CDONTS.NewMail"
objCDO.To = MessageTo
objCDO.From = " "
objCDO.Subject = "Test Repeat Region Send"
objCDO.Body = MailBody
objCDO.Send
Set objCDO = Nothing
%>
</font id=code></pre id=code>
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Edited by - oeastwick on 09/10/2001 15:45:16
Replied 10 Sep 2001 13:22:00
10 Sep 2001 13:22:00 Folkert Jongbloed replied:
IT WORKS!!!!!!!! Great, thanx for the code, it reaully helped me out...but.....I have still some (small?) problem and that is that I can't put the body text into a hidden formelement. When I define the body text in the databse as 'Memo' it won't show up in the element. Alle other files do show up except the memo. Is the content of a hidden form element limited?