I'm working on an email solution in SQL Server ONLY that will use Database Mail to send out HTML formatted emails. The catch is that the images in the HTML need to be embedded in the outgoing email. This wouldn't be a problem if I were using a .net app to generate & send the emails but, unfortunately, all I have is SQL Server.
Is it possible for SQL Server to embed images on its own?
You have two possibilities:
<img src="...">
.cid:
URIs.Each possibility has its downsides:
When the receiving clients are in your control (e.g. same organization), you might be equally fine with either way.
Yes, what you need to do is include the images as attachments and then they can be referenced within the HTML.
Use the @file_attachment
parameter of sp_send_dbmail
You could try to encode the image as base64 and reference it directly in an img tag within the email ( <img src="data:image/png;base64[your encoded image here...]
) but i think most email clients correlate this technique with spam. I think you're better off referencing hosted images or simply attaching it to the email.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With