Open syska opened 12 years ago
Something like the following should work from inside your mailer:
public override MvcMailMessage Populate(Action<MvcMailMessage> action)
{
MvcMailMessage mailMessage = base.Populate(action);
if (mailMessage.IsBodyHtml)
{
mailMessage.Body = new PreMailer.Net.PreMailer().MoveCssInline(mailMessage.Body, true).Html;
}
return mailMessage;
}
Obviously, if you find you have a lot of mailers, make your own base class and have all mailers inherit from that.
Disclaimer: I haven't tested; I'm just going by what I can see on the PreMailer project docs.
I will try that. Havent thought of it .... stupid me :-)
I've tried this approach, but the "mailMessage.Body" is always returning empty.
Best regards.
Hi,
On an other project we just used http://nuget.org/packages/PreMailer.Net/1.1.2 to automatically inline style sheets so the chance is its looks the same in all email clients is better.
I did not however see any options for doing this in MvcMailer or am I just missing this? ( get the output from the Html ) ...
I guess one could just have a seperate Controller action use that view and render it ... and return the Html. Just wanted to make sure I was not missing anything. I don't see any options for this in the https://github.com/smsohan/MvcMailer/wiki
For now I love MvcMailer ... keep up the good work.