Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

display image in email body

anilkp
Kilo Contributor

Hi All, 

We have a requirement to display an image in email body (Not as attachment). Image displays properly when i preview email in service now but image is not seen in customer mail box. 

Below is the logic currently used in email script - url is reference to sys_attachment table where image is located. 

<img src=' + url + '>'

This is not able to fetch image from sys_attachment & load it on to email. 

Kindly let me know how to implement this scenario. 

Thanks. 


Regards,

Anil KP 

 

1 ACCEPTED SOLUTION

Better create a business rule on insert on Attachment table when content type is Image/JPEG that copies the attachment to image (db_image) table & then use the above script.

View solution in original post

11 REPLIES 11

Hemant Goldar
Mega Sage

Hi Anil,

You may find the below thread helpful.
https://community.servicenow.com/community?id=community_question&sys_id=3cd43ec8dbb87b08a39a0b55ca96...

Hope this helps!

Please mark the reply as Helpful/Correct, if applicable.

Regards,
Hemant

Hi Hemanth, db_image works fine but can you please guide to insert on image field of db_image table from sys_attachment. I tried couple of ways but it is copying as attachment to db_image not to field. 

thanks

Jaspal Singh
Mega Patron
Mega Patron

Hi Anil,

 

Try using below in your mail script.

var img = "/ImageName.png"; //give the imagename that is uploaded in image table along with format
var instance = gs.getProperty("instance_name");
var link = "https://" + instance + ".service-now.com";
template.print('<img src="' + link + img + '">');

Hi Jaspal ,This is exactly what i'm doing -  i can only see in service now instance preview. but its not bringing image on actual email.

attachment = sysId_of_image;

var url = gs.getProperty('custome_url') + "/sys_attachment.do?sysparm_referring_url=tear_off&view=true&sys_id=" + attachment ;


template.print(ind.getMessage("Customer Signature ", lang) +' '+ '<img src=' + url + '>' + "<br><br>" );