This topic is locked

Customize runner_mail layout

5/10/2011 7:30:39 PM
PHPRunner General questions
U
unsearcheable author

Hello, after following http://www.asprunner...timely-fashion/ great tip, i find outcome email a bit plain... Alredy messed with html tags and other things, but cannot get it right. How can i put result email in a table, like in phpr reports ?

Thank you.

Sergey Kornilov admin 5/10/2011

You can use any HTML code in your emails. HTML tables are to help here: http://www.w3schools.com/html/html_tables.asp

U
unsearcheable author 5/16/2011



You can use any HTML code in your emails. HTML tables are to help here: http://www.w3schools.com/html/html_tables.asp


Whatever code i use always gives error in html sintax. Do you have any sample so i can understand ?
Right now i have email in plain text like:
"msg1"

"msg2"

"msg3"
and i wanted it in a row repeated for several records.

Sergey Kornilov admin 5/16/2011

Sure, here is the sample:



<table border="1">

<tr>

<td>row 1, cell 1</td>

<td>row 1, cell 2</td>

</tr>

<tr>

<td>row 2, cell 1</td>

<td>row 2, cell 2</td>

</tr>

</table>
C
chaintm 5/16/2011

I use a great program called phpmailer, just look that up in a search , make sure to get the version that is the latest or these options below will not work with the older versions. Look for the one with the class.pop3 file and class.smtp. I will copy paste my code below, this code (as an excample) generates the full email with on the fly values and sends it. Currently I am adding a way to add comments prior to sending to the customer and addition images.
-----------------------------------
if (@$_REQUEST["a"]=="Email")

{

$userid = $_SESSION["UserID"];

$_SESSION["TEMPPRINT"] = 1;
//======upper body = master file customer info from order=======//

global $conn,$strTableName;

$str = "select from order_sales where Order_num='".$_SESSION[$strTableName."_masterkey1"]."'";

$hrs = db_query($str,$conn);

$data7 = db_fetch_array($hrs);

$str = "select
from misc_zip_id_menu where ZIPID='".$data7["Billto_city"]."'";

$hrs = db_query($str,$conn);

$data8 = db_fetch_array($hrs);

$str = "select * from misc_zip_id_menu where ZIPID='".$data7["Shipto_city"]."'";

$hrs = db_query($str,$conn);

$data9 = db_fetch_array($hrs);

$str = "select firstname,lastname from employees where sessionid='".$data7["Employee_ID"]."'";

$hrs = db_query($str,$conn);

$data10 = db_fetch_array($hrs);

$str = "select pay_type_full from bill_pay_type where paytypeid='".$data7["Pay_type"]."'";

$hrs = db_query($str,$conn);

$data14 = db_fetch_array($hrs);

$data11["event_time_start"] = date("m/d/Y",$data7["event_time_start"]);

$data11["event_time_end"] = date("m/d/Y",$data7["event_time_end"]);

$data11["Cust_Chk1"] = 'XXXX-'.substr($data7["Cust_Chk1"],-4);

$str = "select CustSetupNam from order_surface_menu where CustSetupNum='".$data7["Surface_Setup"]."'";

$hrs = db_query($str,$conn);

$data12 = db_fetch_array($hrs);

$str = "select StatuesName from order_statues_menu where StatuesNumber='".$data7["Order_status"]."'";

$hrs = db_query($str,$conn);

$data13 = db_fetch_array($hrs);
//======email body top====//

//----removed.---------//

//---------".$data10["lastname"]."

//-------

//------

$body="<html>

<head>

<title>Invoicing</title>

</head>

<body>

<tr>

<td>

<h2>Your Invoice</h2>

<p>If you need further assistance with your order, please contact your sales representative <strong>".$data10["firstname"]."</strong></p>




<table width=\"600\" height=\"304\" border=\"0\">

<tr>

<td colspan=\"4\"><img src=\"images\amj4u1.JPG\" alt=\"****\" width=\"600\" height=\"90\"></td>

</tr>

<tr>

<td colspan=\"4\">&nbsp;</td>

</tr>

<tr>

<td width=\"72\" height=\"-2\">&nbsp;</td>

<td width=\"300\">Dates: ".$data11["event_time_end"]." - ".$data11["event_time_start"]."</td>

<td>P.O# : ".$data7["Billto_address2"]." INV# : ".$data7["Order_num"]."</td>

<td width=\"2\">&nbsp;</td>

</tr>

<tr>

<td width=\"72\" height=\"-2\">&nbsp;</td>

<td>Setup Time: ".$data7["event_time_delivery"]."</td>

<td>Pickup Time : ".$data7["event_time_pickup1"]."</td>

<td width=\"2\">&nbsp;</td>

</tr>

<tr>

<td width=\"72\" height=\"-2\">&nbsp;</td>

<td>&nbsp;</td>

<td>&nbsp;</td>

<td width=\"2\">&nbsp;</td>

</tr>

<tr>

<td width=\"72\" height=\"-2\">&nbsp;</td>

<td>Billing:</td>

<td >Location:</td>

<td width=\"2\">&nbsp;</td>

</tr>

<tr>

<td width=\"72\" height=\"-2\">&nbsp;</td>

<td>".$data7["Billto_name"]." ".$data7["Billto_Lname"]."</td>

<td>".$data7["Shipto_name"]." ".$data7["Shipto_Lname"]."</td>

<td width=\"2\">&nbsp;</td>

</tr>

<tr>

<td width=\"72\" height=\"-2\">&nbsp;</td>

<td>".$data7["Billto_company"]."</td>

<td>".$data7["Shipto_company"]."</td>

<td width=\"2\">&nbsp;</td>

</tr>

<tr>

<td width=\"72\" height=\"-2\">&nbsp;</td>

<td>".$data7["Billto_address"]."</td>

<td >".$data7["Shipto_address"]."</td>

<td width=\"2\">&nbsp;</td>

</tr>

<tr>

<td width=\"72\" height=\"-1\">&nbsp;</td>

<td>".$data8["CityName"].", ".$data8["StateName"]." ".$data8["ZIPCode"]."</td>

<td>".$data9["CityName"].", ".$data9["StateName"]." ".$data9["ZIPCode"]."</td>

<td width=\"2\">&nbsp;</td>

</tr>

<tr>

<td width=\"72\" height=\"-1\">&nbsp;</td>

<td>".$data7["Cust_email"]."</td>

<td>".$data11["Cust_Chk1"]."</td>

<td width=\"2\">&nbsp;</td>

</tr>

<tr>

<td width=\"72\" height=\"0\">&nbsp;</td>

<td>".$data7["Phone_Home"]."</td>

<td>".$data14["pay_type_full"].", ".$data7["Cust_Date1"]."</td>

<td width=\"2\">&nbsp;</td>

</tr>

<tr>

<td width=\"72\" height=\"1\">&nbsp;</td>

<td>&nbsp;</td>

<td>&nbsp;</td>

<td width=\"2\">&nbsp;</td>

</tr>

<tr>

<td width=\"72\" height=\"11\">&nbsp;</td>

<td colspan=\"2\">Setup: ".$data12["CustSetupNam"]."</td>

<td width=\"2\">&nbsp;</td>

</tr>

<tr>

<td width=\"72\" height=\"11\">&nbsp;</td>

<td colspan=\"2\">Comments: ".$data7["Order_comments"]."</td>

<td width=\"2\">&nbsp;</td>

</tr>

</table>



";
//==== file imaging background=\"images\invoice_r.gif\" =======//

//===== lower body array item listings for order======//

$str20 = "select from order_items where Order_num='".$_SESSION[$strTableName."_masterkey1"]."'";

$hrs20 = db_query($str20,$conn);

while($data20 = db_fetch_array($hrs20))

{

$str = "select ItemName from items where ItemID='".$data20["ItemID"]."'";

$hrs = db_query($str,$conn);

$data22 = db_fetch_array($hrs);

$str = "select Name from modual_panels where ItemID='".$data20["Moduals"]."'";

$hrs = db_query($str,$conn);

$data23 = db_fetch_array($hrs);

{

$body .="

<table width=\"596\" border=\"0\">

<tr>

<td width=\"62\">&nbsp;</td>

<td width=\"33\"align=\"left\" height=\"21\">".$data20["Qty_order"]."</td>

<td width=\"85\"align=\"left\">".$data23["Name"]."</td>

<td width=\"290\"align=\"left\">".$data22["ItemName"]." ".$data20["Misc"]."</td>

<td align=\"right\">".$data20["Sub_total"]."</td>

<td width=\"50\">&nbsp;</td>

</tr>

</table>

";

}}
//===== lower body final costs======//

$str21 = "select
from order_sales where Order_num='".$_SESSION[$strTableName."_masterkey1"]."'";

$hrs21 = db_query($str21,$conn);

$data21 = db_fetch_array($hrs21);

$body .="
<table width=\"596\" border=\"0\">

<tr>

<td height=\"35\" align=\"right\" valign=\"bottom\">".$data21["Order_sub_total"]."</td>

<td width=\"50\">&nbsp;</td>

</tr>

<tr>

<td height=\"21\" align=\"right\" valign=\"bottom\">- ".$data21["Discount"]."</td>

<td width=\"50\">&nbsp;</td>

</tr>

<tr>

<td height=\"23\" align=\"right\" valign=\"bottom\">- ".$data21["Amount_down"]."</td>

<td width=\"50\">&nbsp;</td>

</tr>

<tr>

<td height=\"29\" align=\"right\" valign=\"bottom\">".$data21["Order_total"]." </td>

<td width=\"50\">&nbsp;</td>

</tr>

<tr>

<td height=\"100\">&nbsp;</td>

<td width=\"50\">&nbsp;</td>

</tr>

</table>

</body>

</html>";
//** Send email with new data ****

require_once($_SERVER['DOCUMENT_ROOT'].'/amoonjump4u_invoicing/output/include/phpmailer/class.phpmailer.php');

require_once($_SERVER['DOCUMENT_ROOT'].'/amoonjump4u_invoicing/output/include/phpmailer/class.smtp.php');

//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail = new PHPMailer();

$mail->IsSMTP(); // telling the class to use SMTP

$mail->Host = "mail.amjse.com"; // SMTP server

$mail->SMTPDebug = 1; // enables SMTP debug information (for testing)

// 1 = errors and messages

// 2 = messages only

$mail->SMTPAuth = true; // enable SMTP authentication

$mail->Host = "mail.****"; // sets the SMTP server

$mail->Port = 25; // set the SMTP port for the GMAIL server

$mail->Username = "****"; // SMTP account username

$mail->Password = "n**"; // SMTP account password

$mail->SetFrom('info@****.com',$data10["firstname"]);

$mail->AddReplyTo('info@****.com,$data10["firstname"]);

$mail->Subject = " Invoice Order # ".$data7["Order_num"]."";

$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$address = $data7["Cust_email"];

$mail->AddAddress($address, "Invoicing");

$mail->AddAttachment("images/amj4u1.JPG"); // attachment
--------------------------
((edited out security info but you get the idea))
Finally, I left everything in so you can see how I did a full order with multiple items that would generate on the fly for the email to be sent. If you need any help, let me know. I use this code in the "list before event" and the button is....
// email

global $strTableName;

$str = "<INPUT class=button id=submit5 type=button value=\"Email\" name=submit5 onclick=\"var form = $('#frmAdmin1')[0];form.a.value='Email'; form.submit();\">";

echo $str;

  • please note, this works on phprunner v5.2, I don't believe it will work on v5.3 and above , if I remember correctly they took out the or changed the a.value for arrays, you might have to change that.

Sergey Kornilov admin 5/16/2011

PHPRunner uses PHPMailer in fact.

C
chaintm 5/18/2011



PHPRunner uses PHPMailer in fact.


true, but on older versions (it seems) that the version used doesn't allow for much , if you get the later version with additions as mentioned previous, you can do what I wrote. The default included in phprunner doesn't have these files. Just a thought, might want to look into it.