This topic is locked
[SOLVED]

  Send Email Event, Insert Carriage Return in Text

12/24/2012 2:36:52 PM
PHPRunner General questions
B
bussb author

Hello, I just activated the standard "send email with new data" event on the add screen, Before Record Added. The issue is that the default format that PHPRunner puts the email in does not put any space between the message and then the data report.
So the email I get looks like this:
An Edit has been made to the Deviation Log. Please log into view.Date : 2012-12-18 00:00:00

Site : Bristol

Type : Documentation

Reported_By : aimees

Description : Load sheet not signed.

Description_Reference : 12/120 test

but I want it to be a bit easier to read like this:
An Edit has been made to the Deviation Log. Please log into https://www.cloudqms.com/cla to view.
Date : 2012-12-18 00:00:00

Site : Bristol

Type : Documentation

Reported_By : aimees

Description : Load sheet not signed.

Description_Reference : 12/120 test

Here is my existing email code:

$email="blah@yahoo.com";

$from="email@systemblah.com";

$msg="A new Deviation record has been added to the Deviation Log. Please log into view.<BR><BR>";

$subject="Deviation Added";
foreach($values as $field=>$value)

{

if(!IsBinaryType($pageObject->pSet->getFieldType($field)))

$msg.= $field." : ".$value."\r\n";

}



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

if(!$ret["mailed"])

echo $ret["message"];
C
cgphp 12/24/2012

Try this version:

$email="blah@yahoo.com";

$from="email@systemblah.com";

$msg="A new Deviation record has been added to the Deviation Log. Please log into view.<BR><BR>";

$subject="Deviation Added";
foreach($values as $field=>$value)

{

if(!IsBinaryType($pageObject->pSet->getFieldType($field)))

$msg.= $field." : ".$value."\r\n";

}



$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'htmlbody' => $msg, 'from'=>$from, 'charset' => 'UTF-8'));

if(!$ret["mailed"])

echo $ret["message"];


I have replace body with htmlbody and I have added the charset parameter.

B
bussb author 12/27/2012



Try this version:

$email="blah@yahoo.com";

$from="email@systemblah.com";

$msg="A new Deviation record has been added to the Deviation Log. Please log into view.<BR><BR>";

$subject="Deviation Added";
foreach($values as $field=>$value)

{

if(!IsBinaryType($pageObject->pSet->getFieldType($field)))

$msg.= $field." : ".$value."\r\n";

}
$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'htmlbody' => $msg, 'from'=>$from, 'charset' => 'UTF-8'));

if(!$ret["mailed"])

echo $ret["message"];


I have replace body with htmlbody and I have added the charset parameter.


This worked with one exception, I changed the \r\n to a
to make sure each field started on a new line in the HTML format. Like this:

foreach($values as $field=>$value)

{

if(!IsBinaryType($pageObject->pSet->getFieldType($field)))

$msg.= $field." : ".$value."
";

}


There is one issue, the Record ID (primary key) does not display in the email report. If someone edits a record, it should say which ID was edited so the person receiving the email has a absolute reference to it.

Admin 12/28/2012

Record ID doesn't yet exists before record was added. You can use $keys["Key column name here"] in AfterAdd/AfterEdit events to access the value of key column.