Send email to Teams

haoranhuang
Tera Expert

Hellow My friends

I have  a demand now,I needed to send a email to Teams channels, this email Include picture where is in Attachment[sys_attachment] Table.

I had try base64,and cid two ways but all fall, I can't see the picture .Do attachments need to be added to the email and sent together.

Or there is some other ways

 

 

 

2 ACCEPTED SOLUTIONS

Runjay Patel
Giga Sage

Hi @haoranhuang ,

 

Is your picture attached to demand record or you need to send common picture in every email.

If attachments are in record then use below configuration.

RunjayPatel_0-1735617430199.png

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

 

 

View solution in original post

vishwajeet5550
Mega Guru

To send an email with an embedded image from the sys_attachment table to a Microsoft Teams channel, the image must be properly attached to the email and referenced in the email body. The recommended approach is to retrieve the image from the sys_attachment table using a GlideSysAttachment object, add it to the email as an attachment, and then reference it using a unique Content-ID (cid) in the HTML body of the email. This ensures that the image is embedded properly and appears in the email.

If the cid approach does not work due to limitations in Teams, another option is to host the image on an accessible URL and include the URL in the src attribute of the img tag in the email. Alternatively, you can encode the image in base64 and embed it directly in the email using the data: URI scheme. However, base64 encoding can significantly increase the email size.

Here’s a brief script overview: retrieve the image data using the image's sys_id, attach it to the email, and use the cid in the HTML body to embed it. Make sure to test the email thoroughly, as some email clients may not fully support cid embedding. Hosting the image on a public URL is often a more reliable fallback if embedding issues persist.

 

View solution in original post

3 REPLIES 3

Runjay Patel
Giga Sage

Hi @haoranhuang ,

 

Is your picture attached to demand record or you need to send common picture in every email.

If attachments are in record then use below configuration.

RunjayPatel_0-1735617430199.png

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

 

 

Thank you

but i still want to use the send email action to send email

vishwajeet5550
Mega Guru

To send an email with an embedded image from the sys_attachment table to a Microsoft Teams channel, the image must be properly attached to the email and referenced in the email body. The recommended approach is to retrieve the image from the sys_attachment table using a GlideSysAttachment object, add it to the email as an attachment, and then reference it using a unique Content-ID (cid) in the HTML body of the email. This ensures that the image is embedded properly and appears in the email.

If the cid approach does not work due to limitations in Teams, another option is to host the image on an accessible URL and include the URL in the src attribute of the img tag in the email. Alternatively, you can encode the image in base64 and embed it directly in the email using the data: URI scheme. However, base64 encoding can significantly increase the email size.

Here’s a brief script overview: retrieve the image data using the image's sys_id, attach it to the email, and use the cid in the HTML body to embed it. Make sure to test the email thoroughly, as some email clients may not fully support cid embedding. Hosting the image on a public URL is often a more reliable fallback if embedding issues persist.