close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

repeat region not working in email

Thread began 3/30/2010 2:41 pm by brian177569 | Last modified 4/01/2010 8:06 pm by Eric Mittman | 911 views | 6 replies |

brian177569

repeat region not working in email

Using PC, WINDOWS XP, Dreamweaver 8, ASP, VB SCRIPT

I am trying to add a repeat region within the body of an email which is using a recordset loop to despatch mail. The repeat region displays all the names of the recipients of the emails i.e.

A copy of this email has been sent to:
user 1
user 2
user 2
etc

If I add the repeat region to Universal Email, the loop will only send an email to the 1st user
but all the repeat region names are displayed.

If I remove the repeat region the mail is sent to all recipients and the recordset loop works OK.

THIS VERSION LOOPS THROUGH THE RECORDSET OK BUT NO REPEAT:

<table width="46%" border="1" cellpadding="2" cellspacing="0" bordercolor="#CCCCCC">
<tr>
<td width="28%" class="style1"><div align="right">enquiry date: </div></td>
<td width="72%" class="style1"><div align="left"><%=(rsAFLASenq.Fields.Item("datinsert").Value)%></div></td>
</tr>

<tr>
<td class="style1"><div align="right">company: </div></td>
<td class="style1"><div align="left"><%=(rsAFLASenq.Fields.Item("strcompany").Value)%></div></td>
</tr>
<tr>
<td class="style1"><div align="right">country:</div></td>
<td class="style1"><div align="left"><%=(rsAFLASenq.Fields.Item("strcountry").Value)%></div></td>
</tr>

<tr>
<td class="style1"><div align="right"></div></td>
<td class="style1"><div align="left"><a href="http://www.agcce.com/emaillogin.asp">Visit Login Page to View Request and update Request Diary </a></div></td>
</tr>
</table>

THIS VERSION PRODUCES AN ERROR, BUT STILL SEND EMAIL AND ADDS THE REPEAT REGION BUT ONLY SENDS TO 1st RECIPIENT:

This email was sent to:
<table width="46%" border="0" cellspacing="0" cellpadding="2">
<%
While ((Repeat1__numRows <> 0) AND (NOT rsUsers.EOF))
%>
<tr>
<td><%=(rsUsers.Fields.Item("strname").Value)%></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsUsers.MoveNext()
Wend
%>
</table><br />
<table width="46%" border="1" cellpadding="2" cellspacing="0" bordercolor="#CCCCCC">
<tr>
<td width="28%" class="style1"><div align="right">enquiry date: </div></td>
<td width="72%" class="style1"><div align="left"><%=(rsPTFEenq.Fields.Item("datinsert").Value)%></div></td>
</tr>

<tr>
<td class="style1"><div align="right">company: </div></td>
<td class="style1"><div align="left"><%=(rsPTFEenq.Fields.Item("strcompany").Value)%></div></td>
</tr>
<tr>
<td class="style1"><div align="right">country:</div></td>
<td class="style1"><div align="left"><%=(rsPTFEenq.Fields.Item("strcountry").Value)%></div></td>
</tr>

<tr>
<td class="style1"><div align="right"></div></td>
<td class="style1"><div align="left"><a href="http://www.agcce.com/emaillogin.asp">Visit Login Page to View Request and update Request Diary </a></div></td>
</tr>
</table>

The tables are used for formatting of the email.

many thanks
Brian Welsh

Sign in to reply to this post

brian177569

Update

I have tried using:

<wa_recordset_loop name="rsUsers">
<tr>
<td><%=(rsUsers.Fields.Item("strname").Value)%></td>
</tr>
</wa_recordset_loop>

It gives the repeat but only send the 1st recipient mail.

Sign in to reply to this post

Eric Mittman

If you are having trouble getting this to work with the same rs for the looping and sending you should try creating a new recordset. This way you could have the looping for the names done with one and the looping for the send done with another.

Sign in to reply to this post

brian177569

rs looping

Hi,

I am using 2 recordsets. here is a typical page without the loop in the body and then a snippet with the loop as a repeat region and then another WA loop. I can get around this with adding the recipients manually with a CC, kinda defeats the object of hooking ap a database!

You can see the 2 recordsets below, rsPTFEenq & rsUsers

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/AsahiGuard.asp" -->
<%
Dim rsPTFEenq__MMColParam
rsPTFEenq__MMColParam = "0"
If (Session("ptfeid") <> "") Then
rsPTFEenq__MMColParam = Session("ptfeid")
End If
%>
<%
Dim rsPTFEenq
Dim rsPTFEenq_numRows

Set rsPTFEenq = Server.CreateObject("ADODB.Recordset")
rsPTFEenq.ActiveConnection = MM_AsahiGuard_STRING
rsPTFEenq.Source = "SELECT * FROM dbo.tblPTFE WHERE intPTFEID = " + Replace(rsPTFEenq__MMColParam, "'", "''") + ""
rsPTFEenq.CursorType = 0
rsPTFEenq.CursorLocation = 2
rsPTFEenq.LockType = 1
rsPTFEenq.Open()

rsPTFEenq_numRows = 0
%>
<%
Dim rsUsers
Dim rsUsers_numRows

Set rsUsers = Server.CreateObject("ADODB.Recordset")
rsUsers.ActiveConnection = MM_AsahiGuard_STRING
rsUsers.Source = "SELECT DISTINCT strUsername FROM dbo.tblAGUsers, dbo.tblAGUserProd, dbo.tblCountryProd WHERE dbo.tblAGUsers.intuserID = dbo.tblAGUserProd.intUserID AND dbo.tblAGUserProd.intProdID = dbo.tblCountryProd.intProdID AND dbo.tblCountryProd.intSubProdID = 1"
rsUsers.CursorType = 0
rsUsers.CursorLocation = 2
rsUsers.LockType = 1
rsUsers.Open()

rsUsers_numRows = 0
%>
<!--#include file="WA_Universal_Email/CDONTS_NewMail_VB.asp" -->
<!--#include file="WA_Universal_Email/MailFormatting_VB.asp" -->
<% If rsPTFEenq.Fields.Item("strlang").Value = "Fre" Then
response.Redirect "http://www.agcce.com/french/PTFEenqemail2.asp"
ElseIf rsPTFEenq.Fields.Item("strlang").Value = "Ital" Then
response.Redirect "http://www.agcce.com/italian/PTFEenqemail2.asp"
ElseIf rsPTFEenq.Fields.Item("strlang").Value = "Ger" Then
response.Redirect "http://www.agcce.com/german/PTFEenqemail2.asp"
Else
%>
<%
function WA_Universal_Email_1_SendMail(RecipientEmail)
dim MailObject, MailAttachments, MailBCC, MailCC, MailTo, MailBodyFormat, MailBody, MailImportance, MailFrom, MailSubject
MailAttachments = ""
MailBCC = ""
MailCC = ""
MailTo = ""
MailBodyFormat = ""
MailBody = ""
MailImportance = ""
MailFrom = "AGCCE PTFE web form submission|WA|ptfe@agcce.com"
MailSubject = "PTFE Information Request "

'Global Variables
gAddBCC = ""
gAddCC = ""
gAddRecipient = ""
gBodyFormat = ""
gSetImportance = ""

set WA_MailObject = WAUE_Definition()

if (RecipientEmail <> "") then
set WA_MailObject = WAUE_AddRecipient(WA_MailObject,RecipientEmail)
MailTo = gAddRecipient
gAddRecipient = ""
else
'To Entries
end if

'Attachment Entries

'BCC Entries
MailBCC = gAddBCC

'CC Entries
MailCC = gAddCC

'Character Set

'Body Format
set WA_MailObject = WAUE_BodyFormat(WA_MailObject,0)
MailBodyFormat = gBodyFormat

'Set Importance
set WA_MailObject = WAUE_SetImportance(WA_MailObject,"3")
MailImportance = gSetImportance

'Start Mail Body
MailBody = MailBody & "" & vbCrlf & ""
MailBody = MailBody & "" & vbCrlf & ""
MailBody = MailBody & "<p><span class=" & Chr(34) & "style1" & Chr(34) & ">There is a new PTFE Product Request on the<br />" & vbCrlf & ""
MailBody = MailBody & " AGCCE.com website. Click on the link below to go<br />" & vbCrlf & ""
MailBody = MailBody & " to the Login Page. <br />" & vbCrlf & ""
MailBody = MailBody & " <br />" & vbCrlf & ""
MailBody = MailBody & " Please keep the Request Diary up to date with the <br />" & vbCrlf & ""
MailBody = MailBody & " actions you take on all leads as this will be reported <br />" & vbCrlf & ""
MailBody = MailBody & " on a </span><span class=" & Chr(34) & "style1" & Chr(34) & ">Quarterly </span>basis.</p>" & vbCrlf & ""
MailBody = MailBody & "<table width=" & Chr(34) & "46%" & Chr(34) & " border=" & Chr(34) & "1" & Chr(34) & " cellpadding=" & Chr(34) & "2" & Chr(34) & " cellspacing=" & Chr(34) & "0" & Chr(34) & " bordercolor=" & Chr(34) & "#CCCCCC" & Chr(34) & ">" & vbCrlf & ""
MailBody = MailBody & " <tr>" & vbCrlf & ""
MailBody = MailBody & " <td width=" & Chr(34) & "28%" & Chr(34) & " class=" & Chr(34) & "style1" & Chr(34) & "><div align=" & Chr(34) & "right" & Chr(34) & ">enquiry date: </div></td>" & vbCrlf & ""
MailBody = MailBody & " <td width=" & Chr(34) & "72%" & Chr(34) & " class=" & Chr(34) & "style1" & Chr(34) & "><div align=" & Chr(34) & "left" & Chr(34) & ">"
MailBody = MailBody & (rsPTFEenq.Fields.Item("datinsert").Value)
MailBody = MailBody & "</div></td>" & vbCrlf & ""
MailBody = MailBody & " </tr>" & vbCrlf & ""
MailBody = MailBody & " " & vbCrlf & ""
MailBody = MailBody & " <tr>" & vbCrlf & ""
MailBody = MailBody & " <td class=" & Chr(34) & "style1" & Chr(34) & "><div align=" & Chr(34) & "right" & Chr(34) & ">company: </div></td>" & vbCrlf & ""
MailBody = MailBody & " <td class=" & Chr(34) & "style1" & Chr(34) & "><div align=" & Chr(34) & "left" & Chr(34) & ">"
MailBody = MailBody & (rsPTFEenq.Fields.Item("strcompany").Value)
MailBody = MailBody & "</div></td>" & vbCrlf & ""
MailBody = MailBody & " </tr>" & vbCrlf & ""
MailBody = MailBody & " <tr>" & vbCrlf & ""
MailBody = MailBody & " <td class=" & Chr(34) & "style1" & Chr(34) & "><div align=" & Chr(34) & "right" & Chr(34) & ">country:</div></td>" & vbCrlf & ""
MailBody = MailBody & " <td class=" & Chr(34) & "style1" & Chr(34) & "><div align=" & Chr(34) & "left" & Chr(34) & ">"
MailBody = MailBody & (rsPTFEenq.Fields.Item("strcountry").Value)
MailBody = MailBody & "</div></td>" & vbCrlf & ""
MailBody = MailBody & " </tr>" & vbCrlf & ""
MailBody = MailBody & " " & vbCrlf & ""
MailBody = MailBody & " <tr>" & vbCrlf & ""
MailBody = MailBody & " <td class=" & Chr(34) & "style1" & Chr(34) & "><div align=" & Chr(34) & "right" & Chr(34) & "></div></td>" & vbCrlf & ""
MailBody = MailBody & " <td class=" & Chr(34) & "style1" & Chr(34) & "><div align=" & Chr(34) & "left" & Chr(34) & "><a href=" & Chr(34) & "http://www.agcce.com/emaillogin.asp" & Chr(34) & ">Visit Login Page to View Request and update Request Diary </a></div></td>" & vbCrlf & ""
MailBody = MailBody & " </tr>" & vbCrlf & ""
MailBody = MailBody & "</table>"
'End Mail Body

set WA_MailObject = WAUE_SendMail(WA_MailObject,MailAttachments,MailBCC,MailCC,MailTo,MailImportance,MailFrom,MailSubject,MailBody)

set WA_MailObject = nothing
end function
%>
<%
if (("" = "")) then
'WA Universal Email object="CDONTS NewMail"
'Send Loop Once Per Entry
while (NOT rsUsers.EOF)
WA_Universal_Email_1_SendMail("" & cStr(rsUsers.Fields.Item("strUsername").Value) & "")
rsUsers.MoveNext()
wend
if (rsUsers.CursorType > 0) then
rsUsers.MoveFirst
else
rsUsers.Requery
end if

'Send Mail All Entries
if ("thanks.asp"<>"") then
Response.Redirect("thanks.asp")
end if
end if
%>
<% End if %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>PTFE enquiry email</title>
<style type="text/css">
<!--
.style1 { font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style>
</head>

<body>
<p>&nbsp;</p>
</body>
</html>
<%
rsPTFEenq.Close()
Set rsPTFEenq = Nothing
%>
<%
rsUsers.Close()
Set rsUsers = Nothing
%>

-- - - - - - - - - - - - - - - - - - - - - - - - - -
WHAT I AM TRYING TO ADD:

This email was sent to:
<table width="46%" border="0" cellspacing="0" cellpadding="2">
<%
While ((Repeat1__numRows <> 0) AND (NOT rsUsers.EOF))
%>
<tr>
<td><%=(rsUsers.Fields.Item("strname").Value)%></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsUsers.MoveNext()
Wend
%>
</table><br />

OR:

<wa_recordset_loop name="rsUsers">
<tr>
<td><%=(rsUsers.Fields.Item("strname").Value)%></td>
</tr>
</wa_recordset_loop>

Both of the above disable the loop for the send code:

<%
if (("" = "")) then
'WA Universal Email object="CDONTS NewMail"
'Send Loop Once Per Entry
while (NOT rsUsers.EOF)
WA_Universal_Email_1_SendMail("" & cStr(rsUsers.Fields.Item("strUsername").Value) & "")
rsUsers.MoveNext()
wend
if (rsUsers.CursorType > 0) then
rsUsers.MoveFirst
else
rsUsers.Requery
end if

'Send Mail All Entries
if ("thanks.asp"<>"") then
Response.Redirect("thanks.asp")
end if
end if
%>

Sign in to reply to this post

Eric Mittman

The problem might be present in the code but it would be best for me to test this and see the result that you are getting. If you can post a copy of the db and the files let me know and I can open a ticket so that we can exchange those files in private.

Rite now I'm not sure why it is not working when you have the users repeated like this.

Sign in to reply to this post

brian177569

Hi Eric,

If I add the recipients manually via cc and add the wa code, do you think that will solve the problem. My client is pretty pi**ed that this is an issue so I need to resolve this quickly or they will baile!

Sorry to be a pain!

Brian

Sign in to reply to this post

Eric Mittman

That should be a workaround for this, if you had each user manually listed for the email it should not conflict with the loop that is occurring. I'm not positive this will fix the problem you are experiencing though as I'm not sure why you are having this problem. If you can't get a work around going for it let me know so that I can open up a ticket so info can be exchanged privately.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...