Send emails separated by selection grid with control app
Hi I have a job to select email from a grid suppliers and send them an e-mail communication, the emails are taken and placed in control app but do not start sending emails and tells me error of email recipient, then the emails are not sent please help me ???
Here’s what I did, I have a database structured as follows:
first name; fornitoreschede
id; primary field
email; Email Provider
first name; vendor name
I created a grid for the selection of suppliers to whom you want to send an email.
I entered the code in the grid and its fields are indicated;
id
email
first name
code inserted;
onScriptlnit = [arr_email_to] = array ();
Button type RUN where
OnRecord
[arr_email_to] [] = {email};
OnFinish
if (count ([arr_email_to])> 0)
{
$ var_email_to = “(” .implode (’,’, [arr_email_to]). “)”;
sc_redir (control_email_fornitori, var_email_to = $ var_email_to);
print_r ($ var_email_to);
sc_exit ();
}
Then I created an application control where the fields are created;
email_to = where are selected emails from the grid
email_invio = the email I write by hand as email sender
object = subject field of the email
text = content of the email
I plugged in OnValidate
$ email_sql = “SELECT GROUP_CONCAT (email SEPARATOR ‘;’) FROM fornitorischede WHERE id IN [var_email_to]”;
sc_lookup (rs, $ email_sql);
if (isset (rs {[0] [0]}))
{
var_mail_to $ rs = {[0] [0]};
}
$ var_email_invio email_invio = {};
$ var_oggetto = {object};
$ var_messaggio = {text};
/ **
- Send a simple email
- /
// Email parameters
$ mail_smtp_server = ‘smtp.AAAAAA.com’; // SMTP server name or IP address
$ mail_smtp_user = ‘info@AAAAAAAA.com’; // SMTP user name
$ mail_smtp_pass = ‘bbbbbbbbb’; // SMTP password
$ = $ mail_from var_email_invio; // From email
$ = $ mail_to var_mail_to; // To email
$ = $ mail_subject var_oggetto; // Message subject
$ = $ mail_message var_messaggio; // Message body
$ mail_format = ‘H’; // Message format: (T) ext or (H) tml
// Send email ";
sc_mail_send ($ mail_smtp_server,
$ mail_smtp_user,
$ mail_smtp_pass,
$ mail_from,
$ mail_to,
$ mail_subject,
$ mail_message,
$ mail_format);