Azure / azure-sdk-for-js

This repository is for active development of the Azure SDK for JavaScript (NodeJS & Browser). For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/javascript/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-js.
MIT License
2.05k stars 1.19k forks source link

[Communication email] Allow setting attachment content disposition as inline #25604

Open amxfonseca opened 1 year ago

amxfonseca commented 1 year ago

When using the EmailClient from the recently published @azure/communication-email, we can attach files to the email using the following API:

{ name: string, contentType: string, contentInBase64: string }

While this woks for general attachments (like documents, etc), this interface is quite limited if we want to use the attachments to display images inside our email.

To be able to send emails while avoiding loading external images (which are blocked by default in most email clients), it is a common pattern these days to add an image as attachment and display it using its content ID (eg: <img src="cid:logo" alt="Company"/>)

Unfortunately for this to work reliably on the majority of email clients, the Content-Disposition header should be set as inline, instead of the now default attachment. (eg: Content-Disposition: inline; filename="logo.png"; size=16864;)

And the Content-Id also seems to be randomly generated by Azure (eg. Content-Id: <961cf742-4ea9-445e-96e4-58e256928715>), which makes it impossible to properly reference the image by its own ID from the email body template.

Would be really helpful to allow this properties/headers to be set when adding the attachment, by expanding the current API.

I didn't find any workaround for this, since it seems to not be possible to generate a raw email, and send it using the current client.

mrwerdo commented 1 year ago

I'd like this feature too, not sure whether this is the right place to express my vote.

It seems that the REST API doesn't expose the Content-Disposition attribute for attachments. I'm using the azure-sdk-for-net, and poking around in the code they JSON encode the Attachment type and send it to the rest client which suggests that the Content-Disposition is set server side.

I'm looking for another API now which does expose this.

Ps. I feel like I'm travelling through a maze of tutorials. This article last updated in 2023 compares email technologies and doesn't mention Azure Communication Services, and picking EWS Managed API, it says it's in long term support and points me to Microsoft Graph instead.

ygarasab commented 1 year ago

Also would very much like this feature