close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Email to group of addresses from recordset(s)

Thread began 3/23/2012 10:49 am by alanblazek436860 | Last modified 3/26/2012 7:10 pm by Jason Byrnes | 1991 views | 7 replies |

alanblazek436860

Email to group of addresses from recordset(s)

Hello,
I cannot find a specific answer in the forums that addresses my issue.

I would like to be able to have someone choose a group(s) of email addresses from a recordset based on a "team".

I see that UE can set "to" as one recordset result, however I need to allow users to choose from 5 different "teams". And possibly multiple teams.

I have read forum posts suggesting checkboxes for individual addresses, however not for multiple recorset results.

Questions:

Can UE pull the correct team email addresses from one big recordset based on a selection in the form, or do I need to create multiple recorsets, one for each team?

I was going to use a dropdown to choose, but even if I go with checkboxes, how do I assign the different recordset results (groups of emails) to each drop down, or checkbox.

Just to be absolutely clear, I want a visitor to be able to choose a team(s), fill out the form and have the form results emailed to everyone on that team.

Thanks
Alan

Sign in to reply to this post

Jason ByrnesWebAssist

create a multiple select list that you can use to select the teams:

<select name="teams[]" size="5" multiple="multiple" id="teams">
<option value="Team1">Team1</option>
<option value="Team2">Team2</option>
<option value="Team3">Team3</option>
<option value="Team4">Team4</option>
<option value="Team5">Team5</option>
</select>



then create a recordset that will lookup the users by the selected, using the advanced recordset window, create the recordset as:

SELECT * FROM usersTable WHERE team IN(paramTeam)

create a new variable as:
name: paramTeam
Type: Text
Default Value: -1
Run Time Value: $_POST['teams']


this example recordset is using a table named "usersTable" and a column named "team", the example assumes the teams are stored in the team column using text values like "Team1", "Team1" etc.. You will need to make changes to use the correct table and column names and correct value.

Next, add the following code at line 1 to convert the multiple selections to a comma separated list:

php:
<?php

if($_SERVER["REQUEST_METHOD"] == "POST")     {
    foreach(
$_POST as $key => $val) {
        if(
is_array($_POST[$key])) $_POST[$key] = implode(", "$_POST[$key]);
    }
}
?>



then in universal email, click the to button to go to the advanced to settings page and set the to address to use a recordest loop

Sign in to reply to this post

jtskr25

Jason,

That ALMOST worked for me. Thanks first for your clear, concise reply, it was very helpful.

I still have 2 outstanding issues I cannot resolve:

1. I have created a form and it will send to ONLY one "team" from the multiple list...doesn't matter which, but can only do one at a time. If I CNTL click more than one "team" from the list NO emails will go out to anyone.

2. The email that does go out contains no data from the fields in the form, nor does it show the "from" email address that I specified from a recordset. It only shows the subject I specified in UE. I did not specify a html template for this form, is that required?

Thanks
Alan

Attached Files
WebAssist.zip
Sign in to reply to this post

Jason ByrnesWebAssist

it looks like you have hand coded the recordset loop for the to address?

1) Change this line:

php:
if(is_array($_POST[$key])) $_POST[$key] = implode(", ", $_POST[$key]);



to:

php:
if(is_array($_POST[$key])) $_POST[$key] = implode("', '", $_POST[$key]);




you may need to comment this line:
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;


2) in the from address recordset you are using a session variable, are you sure that session has a value? try adding this code at line 1:

php:
<?php @session_Start(); ?>



if it is still not working, add this code after the body tag for troubleshooting:

php:
<?php echo("SQL: ".$query_GetSender); ?>

post back the sql statement this generates.

for the form contents, the simplest way to get the form data in the email is to use one of the templates.


if you don't use a template, you need to click the DW edit button to design the email body and add the form bindings to the page manually.

Sign in to reply to this post

jtskr25

Getting there....but still cannot send email to mutiple "teams"

1.
The only code I changed in the recordset loop is removing the (s) from teams. Being new to this I wasn't sure what could stay and what needed to match the column name in the database so I made everything "team". I have also changed it back to exactly what you sent where it says "teams" in the recordset loop parameter and the page code, but still no luck.

I have also made the other changes in your most recent suggestions but still no luck on getting the form to email multiple "teams".

Updated code attached.


2. SOLVED
The return on the sql statement you requested after adding the session start is
SQL: SELECT id, email FROM patroller WHERE id = 224661
Before the session start was added it returned -1
The form is now returning the correct email "from" address when the email is sent. There was no session start originally due there being one within a server side include which gets the logged in users name and displays that as a welcome message, but adding it to the form page makes the return address work now.

Attached Files
WebAssist2.zip
Sign in to reply to this post

Jason ByrnesWebAssist

try commeting this line:

php:
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);




change it to:

php:
//$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
Sign in to reply to this post

jtskr25

Unfortunately commenting out that line did not work. The form still only sends if I choose one of the "teams" but will not send any email when choosing multiple teams.

Sign in to reply to this post

Jason ByrnesWebAssist

I have created a support ticket so we can look into this issue further.

To view and edit your support ticket, please log into your support history:
supporthistory.php

If anyone else is experiencing this same issue, please append to this thread.

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...