FluentEmail
FluentEmail copied to clipboard
Question: how do you handle attaching images consumed inside a razor view?
For images inside the razor template I used to create an attachment, get it's cid and set the cid as the image src. This is usually implemented as a method on the model itself so one can use it in razor like: <img src="@Model.EmbedImage("my-logo.png")" alt="my-logo" />
There are two issues though:
- the attachment itself needs to be added to the
FluentEmail.Core.Emailbut the IFluentEmail is not accessible inside the model - the attachment object is not a
System.Net.Mail.Attachmentbut a custom class missing the needed Contentid property
I could probably solve the first issue with a base model class creating an empty IFluentEmail instance and building further fluent properties through this instance but have no idea how to come around the 2nd issue.
In case anyone wonders why attaching images at all - because not all email clients are kind enough to render images from an url.