This topic is locked
[SOLVED]

 Sent Email Event day before

5/1/2011 4:03:54 PM
PHPRunner General questions
U
unsearcheable author

Hello all.
I am trying to make an event to send a email with a report one day before the data field of that record.

I.e. 1 MIKE ORDER9 10-05-2011 (email sent on 09-05-2011 with that record).
How can i do that ?

Sergey Kornilov admin 5/1/2011

I recommend to check this article that explains how to send emails on timely fashion:

http://www.asprunner.com/forums/topic/14793-sample-script-to-send-email-on-timely-fashion/

U
unsearcheable author 5/9/2011



I recommend to check this article that explains how to send emails on timely fashion:

http://www.asprunner.com/forums/topic/14793-sample-script-to-send-email-on-timely-fashion/


Thankyou, i alredy can send emails, but how can i send fields from other tables, place entire select statement in query part ?

N
nti 5/9/2011



but how can i send fields from other tables?


Create new custom view utilizing the table/s and fields you require. Add Send Email Event based on: http://www.asprunner...timely-fashion/

U
unsearcheable author 5/9/2011



Create new custom view utilizing the table/s and fields you require. Add Send Email Event based on: http://www.asprunner...timely-fashion/


Thanks for your answer nti, but how can i automatize this custom view ? I need it to run once a day. Using cron what php can i call since i don't create any php file.

Also can't find Send Email event, there is before process, before display, onload java, etc...

Sergey Kornilov admin 5/9/2011

You can sse DAL's CustomQuery() function and put any SQL query you want there.

U
unsearcheable author 5/9/2011



You can sse DAL's CustomQuery() function and put any SQL query you want there.


In case of the query returns more than one result, how can i send them all in one mail instead of one per mail ?

I like nti aproach, because alredy have report configured and doing the query i want, but i only don't understand how can i shedulle it to run daily... can i call the report php using cron ?

N
nti 5/9/2011



how can i send them all in one mail instead of one per mail ?


Utilize phpMyAdmin and "Create Mysql Table View" using your Custom View Sql.

U
unsearcheable author 5/9/2011



Utilize phpMyAdmin and "Create Mysql Table View" using your Custom View Sql.


Thank you for your answer, but i did it thru query in php file... now i'm having a hard time in doing the loop for all the records, here is how i did:

<?php

include("include/dbcommon.php");

global $dal;

$sql = " Query Query Query ";
$rs = CustomQuery($sql);
$data = db_fetch_array($rs);



$email="mail@domain.com";
while ($data = db_fetch_array($rs))

{
$msg.="Query Field 1 ".$data["Field1"]."\r\n";

$msg.="Query Field 2 ".$data["Field 2"]."\r\n";
}

$subject="Email Title";

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

?>


Now the problem is that is skipping the first record and writing all the others.. how can i fix this ?
Thank you.

Sergey Kornilov admin 5/10/2011

The code itself looks good and nothing suggests why it only sends the latest record.
I recommend to post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.

U
unsearcheable author 5/10/2011



The code itself looks good and nothing suggests why it only sends the latest record.
I recommend to post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.


I figured it out. The problem was that db_fetch_Array is alredy positioning in first record, when it does the while moves foward second... just did do .... while, and it shows all the records now.