Is There a way to display content in HTML

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
mgain2013
Posts: 29
Joined: 2013-02-16 16:12

Is There a way to display content in HTML

Post by mgain2013 » 2013-06-10 19:00

I have a field that is designated as a RICH(HTML)AREA and it is being used in a email hook. Is it possible to to send it as a HTML field so it displays properly? Anything help would be appreciated.



Thanks,
Michael

Tekno Venus
AppGini Super Hero
AppGini Super Hero
Posts: 56
Joined: 2013-01-10 16:37
Location: England
Contact:

Re: Is There a way to display content in HTML

Post by Tekno Venus » 2013-06-12 16:44

Hi,

Indeed there is! Unfortunately due to school and exams and whatnot I cannot provide a custom hook script but I have made this myself. It's a tad complex but serves a purpose. If you need help understanding it, there's a good tutorial on this here: http://css-tricks.com/sending-nice-html-email-with-php/

My hook is here if you would like to borrow and change it. You will need to adapt it for your table and emails etc:

Code: Select all

function drt_after_insert($data, $memberInfo, &$args){

	// Assign the fields of information to  a var called messagedata2
	// Create a HTML Table
	// Strip_Tags to remove HTML from data before emailing
$messageData2 = '<table rules="all" style="border-color: #666;" cellpadding="10">';
$messageData2 .= '<tr><td><b>Name: </b></td><td>';
$messageData2 .= strip_tags ($data['name']) . " </td></tr>";
$messageData2 .= '<tr><td><b>Timestamp: </b></td><td>';
$messageData2 .= strip_tags ($data['time']) . " </td></tr>";
$messageData2 .= '<tr><td><b>Information: </b></td><td>';
$messageData2 .= strip_tags ($data['info']) . " </td></tr>";
$messageData2 .= "<tr><td><b>Update URL: </b></td><td>";
$messageData2 .= strip_tags ($data['source']) . " </td></tr>";
$messageData2 .= "<tr><td><b>System Driver? </b></td><td>";
$messageData2 .= strip_tags ($data['ms']) . " </td></tr>";
$messageData2 .= "</table>";

// To address
$to = '[color=#FF0000]**REMOVED FOR PRIVACY - ENTER AN EMAIL TO SEND MAIL TO**[/color]';
// Subject
$subject = "DRT - New driver added to the DRT";
// Create the message and assign the var $message
$message = "<html><body>";
$message .= '<h1 style = "font: 22px Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-weight:bold; color:#000080;">A New Driver Has Been Added to the DRT.</h1><br />';
$message .= "A driver with the following information was added to the DRT by <strong><a href=geoip.flagfox.net/?ip={$memberInfo['IP']}>{$memberInfo['IP']}</a></strong><br /><br />";
$message .= $messageData2;
$message .= '<br /><br /> To view the driver that has been added, please visit: http://bsodforums.com/drt2/drt_view.php?SelectedID=' . $data['selectedID'];
$message .= '</body></html>';
// From address
$from = "[color=#FF0000]**REMOVED FOR PRIVACY - ENTER AN EMAIL FOR YOUR DOMAIN - I.E. [email protected]**[/color]";
// Name of from sender
$from_name = "Driver Reference Table";
// Create HTML mail
$headers = "From: " . $from_name . "<" . $from . ">" . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
//Send mail
mail($to,$subject,$message,$headers);
		return TRUE;
	}
Hope this helps,
Stephen
Stephen Foulds

Admin, Sysnative Forums -- Sysnative Forums

mgain2013
Posts: 29
Joined: 2013-02-16 16:12

Re: Is There a way to display content in HTML

Post by mgain2013 » 2013-07-27 20:27

Thank you for your help, I will try this out..

Michael

mgain2013
Posts: 29
Joined: 2013-02-16 16:12

Re: Is There a way to display content in HTML

Post by mgain2013 » 2013-10-01 17:01

I am pulling some of the fields from various tables so I need to use $row in place of the $data. Can that be used in the example above interchangeability with $data, or does it require an other syntax. Any help would Be greatly appreciated, as I am closing in on completing my latest application and I am having a issue with the message not displaying correctly.

Thanks,
Michael

mgain2013
Posts: 29
Joined: 2013-02-16 16:12

Re: Is There a way to display content in HTML

Post by mgain2013 » 2013-10-04 14:19

Ok, I have pretty much figured out how to bring in fields from other tables. Not quite perfect, but usable. However I was wondering if anyone knows how to send the HTML formating along with the email, with out stripping it out? I would love to be able to send formatted HTML messages.

Thanks,
Michael

Post Reply