send mail to several addres

Hi all!
I have been trying to setup a mailing form to send to several selected records in my db. but i can’t get success.

I thinking using an array, but i’m not shure how to do it.
Can somebody give me a guide in order to do this?

Thanks

Re: send mail to several addres

If you want help, post your code (just the email section) and someone can assist you.

Regards,
Scott.

Re: send mail to several addres

Hi
Thanks for the response.

Well, in fact i have two applications based on the examples posted in the scriptcase tutorials:

-Users grid (grid)
based on ‘Run Button in a Grid Application (Processing Records)’

-Mail form (control)
based on tutorial send mail

I don’t have any other code.

I’ll really appreciatte your help.
Thanks a lot

Re: send mail to several addres

Did you use the ‘Insert Code’ in the event ?
You can start using this code.

Re: send mail to several addres

Do you want to send emails to all users or a selection made in the grid by the user?

To get the email code Max is referring to, go to the event. Then on the right side you can click on “Send a simple e-mail”. Example code will be inserted for you. You will have to program the processing of the records yourself. To get you started:

Tutorial: http://www.scriptcase.net/phpgenerator/samples/tutoriais/grid/grid44.php
Demo: http://www.scriptcase.net/systems/v5/exemplos_en_us/grid44/grid44.php

Re: send mail to several addres

To all of you guys!
Thanks a lot for all your help. your responses have been fully helpful for me.

I put the simple_mail code in the button option ‘on finish’ and change the value of $Mail_to to $contacts, which is the variable with the email address. and it works!


/**
 * Send a simple email
 */

// Email parameters
$mail_smtp_server = 'localhost';    // SMTP server name or IP address
$mail_smtp_user  = '';          // SMTP user name
$mail_smtp_pass  = '';        // SMTP password
$mail_from    = 'me@mydomain.com';     // From email
$mail_to     = $contacts;     // To email
$mail_subject   = 'test messaje';      // Message subject
$mail_message   = 'this is a test message.'; // 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);

I have another questions:
is there an option to change the value mailto to CC or BCC?

and the last one:
it’s possible to get a fomr and a grid in the same page in order to have an option to write the message to be send?

Really Really Really Thanks a lot.

Re: send mail to several addres

Check documentation on sc_send_mail for sending CC.

You can put a form and a grid in an application of type “container”.

Re: send mail to several addres

You could use a variation of the following:


$cc_list = get_admin_emails($id_send_user); // do not send to original user again 

// use BCC for blind
sc_mail_send( $smtp_server,$smtp_user,$smtp_pass,$email_from,$email_to,$email_subject,$email_body,'H',$cc_list,'CCC',$smtp_port,$smtp_auth,"");



function get_admin_emails($id_skip) {
 // admin emails
 $sql = 'SELECT email_address';
 $sql .= ' FROM rnr_users';
 $sql .= ' WHERE id_level = 9';
 if ($id_skip > 0){
  $sql .= ' AND id_user <> '.$id_skip;
 } 

 sc_lookup(admin_data, $sql);
 if ({admin_data} === false || empty({admin_data})) {
  $admin_list = '';
 } else {
  $i = 0;
  $admin_list = '';
  if (count({admin_data}) > 0) {
   foreach ({admin_data} as $key => $value) {
    $prefix = ($i > 0) ? ';' : '';
    $admin_list = $admin_list . $prefix . $value[0]; 
    $i++;
   }
  } 
 }

 return $admin_list;
} 

Regards,
Scott.

Re: send mail to several addres

Thanks a lot!!
I will try with this examples that you kindly provide me.
Best!!