FluentEmail icon indicating copy to clipboard operation
FluentEmail copied to clipboard

Question: how do you handle attaching images consumed inside a razor view?

Open enriko-riba opened this issue 8 years ago • 0 comments

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:

  1. the attachment itself needs to be added to the FluentEmail.Core.Email but the IFluentEmail is not accessible inside the model
  2. the attachment object is not a System.Net.Mail.Attachment but 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.

enriko-riba avatar Dec 18 '17 08:12 enriko-riba