Page 1 of 1

How can I send automation email via grid information?

Posted: Wed May 15, 2019 3:55 pm
by mohamad
Dear Experts
At the moment, I send email for a special group according to the wiki trigger examples. However this is not ideal for my goal, because users have to change the users of a special group in every time.
It is better to be sent email from grid information.
In my grid, I connected a field of grid to database which gets the user names from database. In this way, user can select his /her intended users. After that, PM must send email for all of users who are selected by him/her in order to be attended in a meeting. For example, if he/she selects individual A and B, PM must send email for A and B. or if he/she chooses A,B and C, PM must send email for A,B and C.
How can I do that?
I was wondering if you could support me to solve it.
Looking forward to your comments
Kind Regards

Re: How can I send automation email via grid information?

Posted: Wed May 15, 2019 11:42 pm
by amosbatto
Your trigger code would be something like this:
Code: Select all
$to = '';
foreach (@=recipientsGrid as $aRow) {
    if (!empty($aRow['emailTo'])) {
        $to .= (empty($to) ? '' : ', ') . $aRow['emailTo'];
    }
}
PMFSendMessage(@@APPLICATION, $from, $to, '', '', 'email subject', 'emailTemplate.html');
Where "recipientsGrid" is your grid's variable and "emailTo" is the ID of the dropdown in the grid to select the user to receive the email.

The SQL of this dropdown should be:
SELECT USR_EMAIL, CONCAT(USR_FIRSTNAME, ' ', USR_LASTNAME) FROM USERS

Re: How can I send automation email via grid information?

Posted: Thu May 16, 2019 4:39 am
by mohamad
Thanks a lot, that was great