This topic is locked
[SOLVED]

 HTML field in my email event

11/29/2010 5:45:26 PM
PHPRunner General questions
H
horsey_kim author

I have created an event in the after records add that email a group of people the results of specific fields. IT works, but my problem is that the "notice" field is a field that has html stored in it. When the email goes out it shows the field value with all the html code in it. What I want is the field to be emailed as html code and not text showing the html tags. I can not seem to get it to work. Anyone have any ideas of how I can get this?
Here is my code:
if($values['mailout'] == "yes")

{
$email="news@mydomain.com";

$from="website@mydomain.com";

$msg="";

$subject=$values['date']."Announcement from OHSET website";
$msg.=$values['title']."\r\r\n";

$msg.=$values['notice']."\r\n";

$msg.=$values['link']."\r\n";
$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];

}

else

{

header("Location: announce_list.php?a=return");

exit();

}
THANKS FOR ANY ADVICE <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=15841&image=1&table=forumtopics' class='bbc_emoticon' alt=':)' />
Kim

H
horsey_kim author 11/29/2010

Found Solution:
YEAH, found what I needed to do. I am leaving this posting on so that if anyone else needs to do something similar they can reference what worked for me <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=54778&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
MY Goal:

Here is the code that worked beautifully! I created a field called "mailout" with a yes or not variable. Anytime we add an announcement and select yes for field mailout, an email is sent out with the announcement fields I wanted. If we selected "no", then it would just return us to the announcement page and not email sent. I put the code in events for "After record updated" (edit screen) and "After record added" (add screen).
Here are the My fields, I used:
mailout = yes or no (pick list)

date = date of the announcement

notice = the html field that we use rte to edit

title = text field

link = link field
HERE IS MY CODE:
if($values['mailout'] == "yes")

{
//** Send email with new data ****
$email="news@mydomain.com";

$from="website@mydomain.com";

$msg="";

$subject=$values['date']." Announcement from My website";
$msg.="<b>".$values['title']."</b><br/><br/>";

$msg.=$values['notice']."</br>";

$msg.=$values['link'];
$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'htmlbody' => $msg, 'charset' => 'UTF-8', 'from'=>$from));
if(!$ret["mailed"])

echo $ret["message"];

}

else

{

header("Location: announce_list.php?a=return");

exit();

}
More Options: You can find out more things you can do by visiting the help screens provided with phprunner 5.3, Just do a search on "runner_mail functions".

G
garethpDevClub member 1/21/2011

Great tip - thanks for posting. THis has been a real help.