Thought this may help . Without having to hardcode email runner event or change when your client wants to change administrators.
I have a view of users ( not to be confused with the admin area ) Make a view of users from your users admin section first
Then use fields
Make another table called newformstable or your choice / make a field called fldemail or your choice. Put all your forms in the list of values in lookup wizard spelled exactly what you are going to use below.
( list of values - and type in all your forms )See bold below . It has to be exactly the name of the before process code below. (case sensitive also )
Make a dropdown and custom view with your fldemail field as link in wizard email field as lookup but custom expression as concat(LastName, ' ' ,FirstName);
Make another field called formsname text ..... for example
Then on each form you want to use to send email in before process event on each table that you want to use add this code .
$rstmp = CustomQuery("select * from newformstable where formsname='yourform'"); //This is an example name of one my forms tables or yours
$datatmp = db_fetch_array($rstmp);
$_SESSION["usersemail"] = $datatmp["usersemail"];
Then in the field for email on each form make readonly field as the usersemail default value = $_SESSION["usersemail"]
Now your newformstable your users admin can decide or change in your custom view users table (newformstable) which person gets email for each of your forms when sending after form is filled . ( Use permission to give access to your admin users on this custom view to do this ) .
No need for hardcode. The field $_SESSION["usersemail"] is your default for the form field email field in your other tables. see below youremailfieldthatyousetupasusersemail
See Help Runner_email documentation for emails. Email Functions
$email=$values["youremailfieldthatyousetupasusersemail"];
$subject="Your Form Subject";
$arr = runner_mail(array('to' => $email, 'subject' => $subject, 'htmlbody' => $email_message, 'charset' => 'UTF-8'));
I use templated emails which works great see here for an example.Templated Emails // use your favorite editor to make html5 templates.
Now your email can go out as HTML / be sure to change body to htmlbody for template emails.
sample template
//*Start Email Form ***PHP / FOR ASP SEE ASP Tempated Email
// load email template
$email_message = file_get_contents("yournameforyourhtmlform"); // design a form in an html editor and use ##fieldtoreplacewithdata## in your form for each field in template , then simply use str_replace see code below.
// replace variables
$email_message = str_replace("##orderdate##",$values["orderdate"],$email_message); // make sure you format date here for php or asp !!!!
$email_message = str_replace("##Employee_name##",$values["Employee"],$email_message);
$email_message = str_replace("##EmployeeID##",$values["EmployeeID"],$email_message);
$email_message = str_replace("##Customer_name##",$values["custname"],$email_message);
$email_message = str_replace("##CustomerID##",$values["CustomerID"],$email_message);
$email_message = str_replace("##posinv##",$values["fldinv"],$email_message);
$email_message = str_replace("##fldavail##",$values["fldavail"],$email_message);
$email_message = str_replace("##fldbrand##",$values["brand"],$email_message);
$email_message = str_replace("##discost##",$values["fldcost"],$email_message);
$email_message = str_replace("##cases##",$values["cases"],$email_message);
$email_message = str_replace("##posqty##",$values["posqty"],$email_message);
$email_message = str_replace("##deliver##",$values["deliver"],$email_message);
$email_message = str_replace("##fldassign##",$values["fldassign"],$email_message);
$email_message = str_replace("##cust_address##",$values["address"],$email_message);
$email_message = str_replace("##cust_town##",$values["town"],$email_message);
$email_message = str_replace("##fldreason##",$values["fldreason"],$email_message);
// send HTML email
$email=$values["fldemail"].",".$values["fldassign"];
$subject="Display Approval Confirmation";
$arr = runner_mail(array('to' => $email, 'subject' => $subject, 'htmlbody' => $email_message, 'charset' => 'UTF-8'));
// if error happened print a message on the web page you can add error messages below see documentation on emails.
This can be done in javascript with a button but beware it will be sent open/text security issues .
That's it . Feel free to reply with any questions?