Description
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.