- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2020 03:47 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2020 04:31 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2020 04:31 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2020 05:59 AM
Hi Jaspal, I tried from db_image to send attachment on body of email & is working fine. Thanks for the info.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2020 08:05 AM
Hi Anil,
Another approach & quicker one would be to get the base64 of the attachment record & then use it in mail script in format below.
var base64is='onlineconvertedvalue';//this value would be long
template.print('<img src="'+base64is+'">');
sys_attachment_doc stores the base64 for each attachment from sys_attachment table.You can GlideRecord sys_attachment_doc table in your mail script along with sys_attachment & get the corresponding base64 in format above. I tested the same & it worked.
Let me know if you need any help on this further as the solution above should work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2021 12:10 AM
Hi Jaspal,
thank you for the tip. I've had similar requirement and I used your solution, though I needed to add more parameters in src:
src='data:image/jpeg;base64, LzlqLzRBQ...<!-- base64 data -->'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2020 04:00 AM
Hi There,
There is an easiest way to add image in email notification. You can embed it in source code of html email body. There you need to provide the name of the image stored in your instance.
For example
<img src="name of image with extension as saved in your instance" width="47" height="48" />.
click on highlighted source code link.
Then it will show the image in email body as shown below:
Please mark this answer as correct and helpful if it resolved your query. And helpful alone if it led you in right direction.
Thanks,
Mohit Kaushik
Mohit Kaushik
ServiceNow MVP (2023-2025)