This topic is locked
[SOLVED]

 Emailing selected records including document as attachment

9/24/2013 11:11:55 AM
PHPRunner General questions
J
jasonfrew author

Hi Everyone,
I would like to email selected records from a list page to an email address that's inputted on the fly.
The process looks like this. Check box of records i wish to send. Click custom button "Email Selected". A pop up box appears "Enter recipient" I enter email address and click send.
i have looked to this part of the manual for instruction

http://www.xlinesoft.com/phprunner/docs/email_selected_records.htm
Im not clear on what i should be changing the red values to.
Will this process send any documents that are attached to the record with the email?
Thanks in advance

C
cgphp 9/24/2013

Check this manual page http://xlinesoft.com/phprunner/docs/runner_mail_function.htm

You can find several examples at the bottom of the page.

J
jasonfrew author 9/24/2013



Check this manual page http://xlinesoft.com/phprunner/docs/runner_mail_function.htm

You can find several examples at the bottom of the page.


Hi Cristian. Its not so much the creating the email body that is the issue for me. the part im having difficulty with is the following
global $dal;

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

$email_list = "";

foreach(@$keys as $keyblock)

{

$arr=explode("&",refine($keyblock["KeyColumn"]));

if(count($arr)<1)

continue;

$arr2=array();

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

$where = KeyWhere($arr2);

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

$datatmp=db_fetch_array($rstmp );

if ($datatmp["EmailField"])

$email_list.=$datatmp["EmailField"].",";
TableName im assuming is the table im selecting the data from. My issue is "KeyColumn" Is this my primary key of this table? Is it any field in my table?
Thanks in advance

C
cgphp 9/24/2013

You don't need to fecth records from the database manually if you have selected the records on the list page.

Check the example 2 on this page: http://xlinesoft.com/phprunner/docs/inserting_button.htm

$button->getNextSelectedRecord()



returns associative arrays with values ​of the records selected on List page (marked with checkboxes). Check this page for more info on getNextSelectedRecord() http://xlinesoft.com/phprunner/docs/button_getnextselectedrecord.htm

J
jasonfrew author 9/24/2013



You don't need to fecth records from the database manually if you have selected the records on the list page.

Check the example 2 on this page: http://xlinesoft.com/phprunner/docs/inserting_button.htm

$button->getNextSelectedRecord()



returns associative arrays with values ​of the records selected on List page (marked with checkboxes). Check this page for more info on getNextSelectedRecord() http://xlinesoft.com/phprunner/docs/button_getnextselectedrecord.htm


Thanks Cristian. I have now got the application emailing me the selected contents. I now need to find a way for me to enter the email address i want the email sent to.
The examples you sent on sending an email with an attachement had the file hard coded into them. I need the email to pick up the file from the database information and attach it from the drive its stored on
Kind regards
Jason

C
cgphp 9/24/2013

You can ask the user to enter a text string with a prompt box. Check the prompt tutorial on this page http://www.w3schools.com/js/js_popup.asp
You can fetch file records from database using the CustomQuery method http://xlinesoft.com/phprunner/docs/customquery.htm

J
jasonfrew author 9/25/2013



You can ask the user to enter a text string with a prompt box. Check the prompt tutorial on this page http://www.w3schools.com/js/js_popup.asp
You can fetch file records from database using the CustomQuery method http://xlinesoft.com/phprunner/docs/customquery.htm


Thanks Cristian. While i can see the process in how the elements are created. I cant see how i would include that into the button i have created to email the selected records.
While this lnk shows me how to create a pop up box asking for information to be incerted. It doesnt tell me where in the custom button to put the code or how to send the information entered to the process so the process knows what email address the email should be sent to.

C
cgphp 9/25/2013

Check the manual page of the button http://xlinesoft.com/phprunner/docs/inserting_button.htm
A sample code for your case:
Client before

ctrl.setEnabled();

var email = prompt("Please enter your email","");

if (email != null && email != "")

{

params['email'] = email;

return true;

}

else

{

return false;

}


Server
Here you can fetch the email entered by the user accessing the $params['email'] array.
Client after

alert("Mail sent successfully");


This is only a sample code for the button. Add validation and security checks on the Server because you are accepting free text string from user.

J
jasonfrew author 9/25/2013



Check the manual page of the button http://xlinesoft.com/phprunner/docs/inserting_button.htm
A sample code for your case:
Client before

ctrl.setEnabled();

var email = prompt("Please enter your email","");

if (email != null && email != "")

{

params['email'] = email;

return true;

}

else

{

return false;

}


Server
Here you can fetch the email entered by the user accessing the $params['email'] array.
Client after

alert("Mail sent successfully");


This is only a sample code for the button. Add validation and security checks on the Server because you are accepting free text string from user.


Thanks Cristian. Im very rusty with PHPRunner. ive not developed a project with it in quite some time.

J
jasonfrew author 9/25/2013



Thanks Cristian. Im very rusty with PHPRunner. ive not developed a project with it in quite some time.


Where can i get access to the $params['email'] array i cant see that in the manual or in the application
Thanks in advance

C
cgphp 9/25/2013

Check the yellow part of the button window (

J
jasonfrew author 9/25/2013