Forum Discussion

JeffBoettcher's avatar
JeffBoettcher
Copper Contributor
Nov 29, 2022

Programmatically post a message to a Teams channel with an inline image?

I'm developing an automated process and for part of this, I want to post a message to Teams.  In this message, I want to have an inline image.

 

The most straightforward solution seemed to be to get the email address for the channel, and just send an email.  That works, but as this page suggests, it has numerous limitations.

 

The first one I hit involved sending the image as an attachment and using cid in my html.  The second bullet in the note explains why this doesn't work - Teams name-mangles attachments.

 

I then tried embedding the image as a base64-encoded string in the html in the body of my email.  This kind of works, but over some cripplingly-small (around 24k) threshold of size, Teams refuses to display the image, in favor of telling me my email is too large for Teams to display it.

 

This doesn't seem like that unusual a thing to want to do, for as hard as it is turning out to be.  Does anyone have any recommendations?  Am I missing something obvious?

 

I wasn't sure if this would be best posted here or the main MicrosoftTeams community - it kind of straddles the line of development and regular use.  Feel free to re-direct.  Thanks!

3 Replies

Resources