Buy Now
Sign in

Email multiple table records

vividal , March 11 2019, 00:43
V
vividal 117
March 11 2019, 00:43 #384645
I would like to have a form where I can enter a message into a textarea field and email a set of rows from a table. I have the form set, the email function works if I use a text field in the form to be the recipient. I have a read_data that pulls the records I want that contains the email addresses, but I can't figure out how to do the loop event or if I need a loop. OR should I be doing this in CC6 instead of CF6?
healyhatman 7
March 11 2019, 01:32 #384646
So you just want the emails out of the read data to be used as recipients, is that right? Then put this in the recipients.
{var:read_data#.[n].model.email}
Replace # with the number in the black label of your read data action, model with your read data model name, and email with your email field name.
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
V
vividal 117
March 11 2019, 01:40 #384647
Does the email command need to be in a loop event? I placed your syntax (adjusted for my read_data, model & field but it is still blank. The read_data is in the load section. do I need it in the submit section?
V
vividal 117
March 11 2019, 01:53 #384648
Ok getting closer. moved the read_data to the submit section and now the emails show up in the recipients array but now the result is could not sent.
[email15] => Array
(
[recipients] => Array
(
[0] => REMOVED
[1] => test2@vividal.com
[2] => test4@vividal.com
[3] => test6@vividal.com
[4] => test7@vividal.com
[5] => test2@vividal.com
)

[subject] => test 4
[body] => test 4
[from_name] => REMOVED
[from_email] => REMOVED
[reply_name] => REMOVED
[reply_email] => REMOVED
[result] => the Mail could not be sent.
[var] =>
)
healyhatman 7
March 11 2019, 02:09 #384649
I assume [0] isn't literally REMOVED, right?
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
V
vividal 117
March 11 2019, 02:09 #384650
no I removed the address b/c it isnt a "test" address the same for the from and reply info.
healyhatman 7
March 11 2019, 02:10 #384651
And the FROM_EMAIL, that's on your domain right?
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
V
vividal 117
March 11 2019, 02:11 #384652
it works just fine until I put in the var statement (ie use a static entry only in the recipients field or have a {data:send_to} field in the form and put that in the recipients field)
healyhatman 7
March 11 2019, 02:14 #384653
OK odd. Try {var.join[, ]:read_data#.[n].mdoel.email}
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
V
vividal 117
March 11 2019, 02:18 #384654
no go.
[email15] => Array
(
[recipients] => Array
(
[0] => test2@vividal.com
test4@vividal.com
test6@vividal.com
test7@vividal.com
test2@vividal.com
)

[subject] => test 1
[body] => test 1
[from_name] => REMOVED
[from_email] => REMOVED
[reply_name] => REMOVED
[reply_email] => REMOVED
[result] => the Mail could not be sent.
[var] =>
)
V
vividal 117
March 11 2019, 02:26 #384655
ok so i removed the join and it appears to be an issue if there are more than 5 entries in the recipients array. Thoughts on what is causing that or how to fix it?
V
vividal 117
March 11 2019, 02:30 #384656
CHANGE THAT. The issue is if there is a duplicate email address. my example had test2 listed twice. If I change the test2 to something unique I can send the email even if there are 7 email addresses.
healyhatman 7
March 11 2019, 03:10 #384657
Right then well you need to use DISTINCT(model.email):model.email in your Fields to Retrieve for your email list. data read.
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
V
vividal 117
March 11 2019, 03:19 #384658
So I have added DISTINCT(Emails2.parents_email_1):Emails2.parents_email_1 to my read_data Fields to retrieve and now the entries in the array are blank??? [0] is the entry from the "send_to" field, not the read_data
my Recipients List is {data:send_to},{var:read_data21.[n].Emails2.parent_email_1}
[email15] => Array
(
[recipients] => Array
(
[0] => test8@vividal.com
[1] =>
[2] =>
[3] =>
[4] =>
[5] =>
)

[subject] => test 1
[body] => trest
[from_name] => Robert Scott
[from_email] => REMOVED
[reply_name] => Robert Scott
[reply_email] => REMOVED
[result] => the Mail could not be sent.
[var] =>
)
V
vividal 117
March 11 2019, 03:20 #384659
The select statement doesnt look right
  [read_data21] => Array
(
[log] => Array
(
[0] => SELECT `Emails2`.`team_id` AS `Emails2.team_id` FROM `lov_team_emails1` AS `Emails2` WHERE `Emails2`.`team_id` = '7' LIMIT 10000;
)

[var] => Array
(
[0] => Array
(
[Emails2] => Array
(
[team_id] => 7
)

)
V
vividal 117
March 11 2019, 03:24 #384660
I have a typo in my DISTINCT statement....so hang on
V
vividal 117
March 11 2019, 03:31 #384661
well fixing the typo in the field name has made it worse. Now i am getting this error when I hit the send button on the form:
1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DISTINCT(`Emails2`.`parent_email_1`) AS `Emails2.parent_email_1` FROM `lov_team_' at line 1
Emails2 is the model from read_data21 and parent_email_1 is the field I want (if I add the "s" back to parent, I dont get the error but there is no field with that name)
healyhatman 7
March 11 2019, 03:47 #384662
Works for me. What have you got your return type set to? Screenshot your read data action ?
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
V
vividal 117
March 11 2019, 03:52 #384663
Not sure where the return type you are asking about would be located. I have not changed any of the defaults. read_data attached
Attachments
read-01.png
read-01.png
(37.34 KiB)
64 Downloads/Views
read-02.png
read-02.png
(36.12 KiB)
66 Downloads/Views
read-01.png
read-01.png
(37.34 KiB)
68 Downloads/Views
read-02.png
read-02.png
(36.12 KiB)
66 Downloads/Views
V
vividal 117
March 11 2019, 04:02 #384664
OK FIGURED IT OUT!!!!
I moved my DISTINCT Field to retrieve above my team_id field and it worked.