This topic is locked

Email a record from a button

3/24/2014 1:59:25 PM
PHPRunner General questions
D
dustinforehand author

Can anyone please help me.

I have a table called log

The fields are Log_ID, User, Case, Area, Date_Logged, Courier, Tracking_Number, Email

I would like to add a button on the view and add page to send record to the email address saved in the email field and also CC a static email address.
I tried following a few examples in the forums, but I am new to php programmming and keep messing it up. Anyone willing to help would be greatly appreciated.

Also was also wondering if there was a way to enter a email when the button is clicked.

Example. When I click the button a box pops asking who would you like to send this to and I can enter the email address there, and also have it CC a static email.
Anyhelp greatly appreciated.

Sergey Kornilov admin 3/25/2014

You can find examples of sending an email at http://xlinesoft.com/phprunner/docs/runner_mail_function.htm
If you need to ask user to provide an email address use Javascript function prompt():

http://www.tizag.com/javascriptT/javascriptprompt.php

D
dustinforehand author 3/28/2014

I have added a button on the list page and use the follow code, When I click the button it does not do anything

My Table is: log

My Fields are:log_id, user, case
global $dal;

$dal_TableName = $dal->Table("log");

$body="";

while ( $data = $button->getNextSelectedRecord() ) {

$arr=explode("&",refine($data["log_id"]));

if(count($arr)<1)

continue;

$arr2=array();

$arr2["log_id"]=urldecode(@$arr[0]);

$where = KeyWhere($arr2);

$rstmp = $dal_TableName->Query($where,"");

$datatmp=db_fetch_array($rstmp );

$body .= "log_id: " . $datatmp['log_id'] . "\n";

$body .= "User: " . $datatmp['user'] . "\n";

$body .= "Case: " . $datatmp['Case'] . "\n-----------\n\n";

}
// send the email

$email="myemail@gmail.com";

$subject="Sample subject";

$arr = runner_mail(array('to' => $email, 'subject' => $subject,'body' => $body));

$result["txt"] = "Emails were sent.";
// if error happened print a message on the web page

if (!$arr["mailed"]) {

$errmsg = "Error happened:
";

$errmsg.= "File: " . $arr["errors"][0]["file"] . "
";

$errmsg.= "Line: " . $arr["errors"][0]["line"] . "
";

$errmsg.= "Description: " . $arr["errors"][0]["description"] . "
";

$result["txt"] = $errmsg;

}



You can find examples of sending an email at http://xlinesoft.com/phprunner/docs/runner_mail_function.htm
If you need to ask user to provide an email address use Javascript function prompt():

http://www.tizag.com/javascriptT/javascriptprompt.php

Sergey Kornilov admin 3/28/2014