How to clearly format HTM and Text email data

wakespirit
Kilo Guru

Dear all,

I am creating through a notification email script an email content which is collecting record data and display them in a nice HTML table.

This works nicely when email is read correctly in html.

Now in email form we can also define content for text email format.

Based on my notification email scripting, does it means I need to have 2 different script wich handle HTML and Text rendering ?

regards

5 REPLIES 5

I do not understand what you mean...

my mail script is as below

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
		
	var assets = event.parm1.split(',');
	gs.log("CAL : ASSETS LENGTH : " + assets.length.toString());
	
	template.print("<h2>List of "  + assets.length.toString()+ " records retire or having Cost center changed</h2>. \n\n");
	template.print("<table border=1 bordercolor=black style='width:100%'>");
	template.print("<tr><th align='left'>Asset Tag</th><th align='left'>Model</th><th align='left'>Status</th><th align='left'>SubStatus</th><th align='left'>Cost Center</th></tr>");
	
	//var gr = new GlideRecord('alm_asset');
	
	for (i=0; i < assets.length; i++){
		gs.log("CAL : RECORD ID : " + assets[i]);
		var gr = new GlideRecord ('alm_asset');
		gr.get(assets[i]);
		
		gs.log("CAL : RECORD TAG : " + gr.getValue('asset_tag'));
		gs.log("CAL : RECORD MODEL : " + gr.getDisplayValue('model'));
		gs.log("CAL : RECORD STATUS : " + gr.getDisplayValue('install_status'));
		gs.log("CAL : RECORD COST CENTER : " + gr.getDisplayValue('cost_center'));
		
		template.print('<tr><td>'+gr.getValue('asset_tag')+'</td><td>'+gr.getDisplayValue('model')+'</td><td>'+gr.getDisplayValue('install_status')+'</td><td>'+gr.getDisplayValue('substatus')+'</td><td>'+gr.getDisplayValue('cost_center')+'</td></tr>');
	}
		
	template.print("</table>");
		
		
	})(current, template, email, email_action, event);