cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Email body formatting

khayes1
13-Aquamarine

Email body formatting

Hi,

this may be a bit of a simplistic question for some of you but I wanted to know how I can format the body text of the email alerts I send out. Currently I just use a plain text string, but it doesn't look particularly professional. I understand (or can read up on) html tags, what I don't understand is how I can enter dynamic data (property values) into the html. The dynamic data can be different every time

so currently I would do something like below where the values in bold are taken from the asset properties.

var params =

{

subject: "Fault State on ASSET " + source /* STRING */,

from: "my.iot@gmail.com (do not reply)" /* STRING */,

to: "user1@gmail.com" /* STRING */,

bcc: "user2@gmail.com" /* STRING */,

body: "Remote Asset " +source+" (" + me.MachineName + ") has encountered a fault!      [1."+row.eventid+" "+row.description+"]. If problem persists please contact your local supplier"

};

// no return

Things["My.MailServer"].SendMessage(params);

Would anyone have a couple of examples, or point me in the direction of some documentation?

Thanks,

K

2 REPLIES 2
mlähde
3-Visitor
(To:khayes1)

Hi! Just include your HTML as part of the body parameter string. Say, you want to write the source in bold:

body: "Remote Asset <b>" +source+"</b> (" + me.MachineName + ") has encountered a fault!"

If your HTML includes attributes remember to escape the double quotes (\") or use single quotes.

khayes1
13-Aquamarine
(To:mlähde)

Hi,

thank for the reply, appreciate you taking the time. I did try the above, but unfortunately it didn't work for me. The result was an email body as shown below

"Remote Asset <b>" +source+"</b> (" + me.MachineName + ") has encountered a fault!"


Any ideas where I might have gone wrong?

Thanks,

K


Announcements