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

Copper Contributor

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

@JeffBoettcher - Can you please go through and see if this Create an Incoming Webhook - Teams | Microsoft Learn , https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/what-are-webhooks-... solves your requirement. Incoming Webhooks help in posting messages from apps to Teams channels. You can post cards along with images.

@Meghana-MSFT

 

Thanks Meghana!  I'll have to look into this.  Unfortunately other priorities have slowed my progress in doing so for the time being.

 

One follow-up question if you don't mind.  In the event I run into issues using web hooks for this use-case, is there a process for requesting an increase to a limit like the 24KB one documented here?

@JeffBoettcher - Currently it is not possible to increase the size limits. 

 

Thanks,

Meghana

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

If the response is helpful, please click "**Mark as Best Response**" and like it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.