This topic is locked
[SOLVED]

 Send an email to multiple addresses.

12/30/2013 11:37:29 PM
PHPRunner General questions
S
SkyForum author

I have an add form. It has 3 cascading drop down fields and one text area. The 3rd field can be from one to 5 email addresses.
Here's the event:
/** Send email with new data ****
$email="email@email.com"; [b]

$from="manager@xxxxxxxxxxxxxx.com";

$msg="";

$subject="Tag Session Performed";
$msg.= "Property Name: ".$values["Property"]."\r\n";
$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];
[color="#0000FF"]Thank you ....

Sergey Kornilov admin 12/31/2013

Instead of

$email="email@email.com";



try

$email=$values["FieldNameThatStoresEmailAddresses"];
S
SkyForum author 12/31/2013



Instead of

$email="email@email.com";



try

$email=$values["FieldNameThatStoresEmailAddresses"];



I have tried that. It produces the following error:
You must provide at least one recipient email address.
There is another issue as well (might be related). When I try and populate the fields with other information from the form (like the Property or ContactName field) All I get is the keyid, not the actual names. (Property Name: 1)
Here is the current setup I am using in the

'After Record Added' Event
;

$from="manager@xxxxxxxxxxxx.com";

$msg="";

$subject="Tag Session Performed";
$msg.= "Good Morning ".$values["ContactName"]."\r\n";

$msg.= "Property Name: ".$values["Property"]."\r\n";

$msg.= "Message From Dispatch --- ".$values["ContactMessage"]."\r\n";
$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];
[color="#000000"]The funny part is the 'ContactMessage' displays just fine in the email. Could it be an issue because I am drawing the other fields from dropdowns that are looking the data up on other tables? (Property, ContactName and ContactEmail are all the result of drop down choices).

[/color]

S
SkyForum author 12/31/2013

Ok, we're all in trouble now. I'm answering my own threads. lol
I found part of my issue. I had the dropdowns set to link to the id, reset them to link to the field instead. Solved my id problem except for the property name field. I also had to unset a couple session values so the redirect didn't limit the values listed in the violations list page.
unset($_SESSION["violations_mastertable"]);

unset($_SESSION["sessionnotify_mastertable"]);

//** Send email with new data ****
$email=$values["ContactEmail"];

$from="manager@xxxxxxxxxxxxx.com";

$msg="";

$subject="Tag Session Performed";
$msg.= "Good Morning ".$values["ContactName"]."\r\n";

$msg.= "Property Name: ".$values["Property"]."\r\n"; [color="#FF0000"]<---------------------------- Still shows as an id.

$msg.= "Message From Dispatch --- ".$values["ContactMessage"]."\r\n";
$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];
//** Redirect to another page ****

header("Location: violations_list.php");

exit();

[/color]
The only remaining problem is I cannot seem to get the name of the property to display in the email.
Here's the relationships. The 'Property' table has a 1 to many with the 'sessioncontacts' table which in turn, has a 1 to many relationship with the 'sessionnotify' table. We are working on the sessionnotify_add page.

C
copper21 12/31/2013

You can lookup the name of the property via the link. I am guessing that the "Property" Field is showing the ID number/link of the line of data in the Property Table?
Put this before the send email area
global $conn;

$strSQLSelect = "SELECT * FROM PROPERTYTABLE WHERE PROPERTYID = ".$values['Property']."";

$rsSelect = db_query($strSQLSelect,$conn);

$data=db_fetch_array($rsSelect);
Then replace the line:
$msg.= "Property Name: ".$values["Property"]."\r\n";
with
$msg.= "Property Name: ".$data["PROPERTY_NAME_FIELD"]."\r\n";

S
SkyForum author 12/31/2013



You can lookup the name of the property via the link. I am guessing that the "Property" Field is showing the ID number/link of the line of data in the Property Table?
Put this before the send email area
global $conn;

$strSQLSelect = "SELECT * FROM PROPERTYTABLE WHERE PROPERTYID = ".$values['Property']."";

$rsSelect = db_query($strSQLSelect,$conn);

$data=db_fetch_array($rsSelect);
Then replace the line:
$msg.= "Property Name: ".$values["Property"]."\r\n";
with
$msg.= "Property Name: ".$data["PROPERTY_NAME_FIELD"]."\r\n";


That's the ticket! You are now my bestest friend in the whole wide world!
Thank You!