MvcMailer icon indicating copy to clipboard operation
MvcMailer copied to clipboard

HTML Body PostProcessor (integrating PreMailer)

Open hernangm opened this issue 12 years ago • 4 comments

The best bet to styling html emails is to set the style attribute in the corresponding tags. However, most people usually have their style definitions in separate css files. There is plenty of documentation about this on the web (http://css-tricks.com/using-css-in-html-emails-the-real-story/).

So I have modified mvc.mailer so html body is passed through a list of configured post processors. One of this post-processor (based on the premailer library) removes style definition from the head tag and apply the rules to the corresponding tags in the body.

I followed the preprocessor pattern of SquishIt library. I hope this modification gets integrated to the master branch.

You've done a great job with Mvc.Mailer. I am using it in several projects. Thanks guys!

hernangm avatar Feb 02 '13 17:02 hernangm

Thanks for this. I'll probably need a bit if time to look at this, but I surely will.


Sent from my iPhone Sohan SM

On 2013-02-02, at 10:52 AM, Hernan Marano [email protected] wrote:

The best bet to styling html emails is to set the style attribute in the corresponding tags. However, most people usually have their style definitions in separate css files. There is plenty of documentation about this on the web ( http://css-tricks.com/using-css-in-html-emails-the-real-story/).

So I have modified mvc.mailer so html body is passed through a list of configured post processors. One of this post-processor (based on the premailer library) removes style definition from the head tag and apply the rules to the corresponding tags in the body.

I followed the preprocessor pattern of SquishIt library. I hope this modification gets integrated to the master branch.

You've done a great job with Mvc.Mailer. I am using it in several projects.

Thanks guys!

You can merge this Pull Request by running

git pull https://github.com/hernangm/MvcMailer master

Or view, comment on, or merge it at:

https://github.com/smsohan/MvcMailer/pull/81 Commit Summary

  • adding inline Css transformation
  • gitignore
  • subiendo cambios
  • spliting projects
  • ultimos cambios
  • deleting trash
  • borrando trash
  • mas cambios
  • mas cambios

File Changes

  • M .gitignorehttps://github.com/smsohan/MvcMailer/pull/81/files#diff-0(65)
  • A .nuget/NuGet.Confighttps://github.com/smsohan/MvcMailer/pull/81/files#diff-1(6)
  • A .nuget/NuGet.exehttps://github.com/smsohan/MvcMailer/pull/81/files#diff-2(0)
  • A .nuget/NuGet.targetshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-3(153)
  • A Mvc.Mailer.PreMailer/Mvc.Mailer.PreMailerPostProcessor.csprojhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-4(78)
  • A Mvc.Mailer.PreMailer/PreMailerPostProcessor.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-5(16)
  • A Mvc.Mailer.PreMailer/Properties/AssemblyInfo.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-6(36)
  • A Mvc.Mailer.PreMailer/packages.confighttps://github.com/smsohan/MvcMailer/pull/81/files#diff-7(4)
  • M Mvc.Mailer.Test/ExtensionMethods/HtmlHelperExtensionsTest.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-8(49)
  • M Mvc.Mailer.Test/ExtensionMethods/UrlHelperExtensionsTest.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-9(163)
  • M Mvc.Mailer.Test/LinkedResourceProviderTest.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-10(101)
  • M Mvc.Mailer.Test/MailerBaseTest.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-11(682)
  • M Mvc.Mailer.Test/Mocks.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-12(75)
  • M Mvc.Mailer.Test/Mvc.Mailer.Test.csprojhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-13(181)
  • M Mvc.Mailer.Test/Mvc.Mailer.Test.csproj.userhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-14(24)
  • R Mvc.Mailer.Test/MvcMailMessageTest.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-15(152)
  • M Mvc.Mailer.Test/SmtpClientWrapperTest.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-16(76)
  • M Mvc.Mailer.Test/StringResultTest.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-17(30)
  • M Mvc.Mailer.Test/TestSmtpClientTest.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-18(41)
  • D Mvc.Mailer.Test/bin/Debug/Chrysanthemum.jpghttps://github.com/smsohan/MvcMailer/pull/81/files#diff-19(0)
  • D Mvc.Mailer.Test/bin/Debug/Moq.dllhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-20(0)
  • D Mvc.Mailer.Test/bin/Debug/Moq.pdbhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-21(0)
  • D Mvc.Mailer.Test/bin/Debug/Moq.xmlhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-22(5120)
  • D Mvc.Mailer.Test/bin/Debug/Mvc.Mailer.Test.dllhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-23(0)
  • D Mvc.Mailer.Test/bin/Debug/Mvc.Mailer.Test.dll.VisualState.xmlhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-24(15)
  • D Mvc.Mailer.Test/bin/Debug/Mvc.Mailer.Test.pdbhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-25(0)
  • D Mvc.Mailer.Test/bin/Debug/Mvc.Mailer.dllhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-26(0)
  • D Mvc.Mailer.Test/bin/Debug/Mvc.Mailer.pdbhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-27(0)
  • D Mvc.Mailer.Test/bin/Debug/TestResult.xmlhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-28(132)
  • D Mvc.Mailer.Test/bin/Debug/content/Views/web.config.transformhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-29(19)
  • D Mvc.Mailer.Test/bin/Debug/content/web.config.transformhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-30(18)
  • D Mvc.Mailer.Test/bin/Debug/nunit.framework.dllhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-31(0)
  • D Mvc.Mailer.Test/bin/Debug/nunit.framework.xmlhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-32(10385)
  • D Mvc.Mailer.Test/bin/Release/Chrysanthemum.jpghttps://github.com/smsohan/MvcMailer/pull/81/files#diff-33(0)
  • D Mvc.Mailer.Test/bin/Release/Moq.dllhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-34(0)
  • D Mvc.Mailer.Test/bin/Release/Moq.pdbhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-35(0)
  • D Mvc.Mailer.Test/bin/Release/Moq.xmlhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-36(5120)
  • D Mvc.Mailer.Test/bin/Release/Mvc.Mailer.Test.dllhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-37(0)
  • D Mvc.Mailer.Test/bin/Release/Mvc.Mailer.Test.dll.VisualState.xmlhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-38(15)
  • D Mvc.Mailer.Test/bin/Release/Mvc.Mailer.Test.pdbhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-39(0)
  • D Mvc.Mailer.Test/bin/Release/Mvc.Mailer.dllhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-40(0)
  • D Mvc.Mailer.Test/bin/Release/Mvc.Mailer.pdbhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-41(0)
  • D Mvc.Mailer.Test/bin/Release/TestResult.xmlhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-42(135)
  • D Mvc.Mailer.Test/bin/Release/content/Views/web.config.transformhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-43(19)
  • D Mvc.Mailer.Test/bin/Release/content/web.config.transformhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-44(23)
  • D Mvc.Mailer.Test/bin/Release/nunit.framework.dllhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-45(0)
  • D Mvc.Mailer.Test/bin/Release/nunit.framework.xmlhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-46(10385)
  • D Mvc.Mailer.Test/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cachehttps://github.com/smsohan/MvcMailer/pull/81/files#diff-47(0)
  • D Mvc.Mailer.Test/obj/Debug/Mvc.Mailer.Test.csproj.FileListAbsolute.txthttps://github.com/smsohan/MvcMailer/pull/81/files#diff-48(15)
  • D Mvc.Mailer.Test/obj/Debug/Mvc.Mailer.Test.dllhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-49(0)
  • D Mvc.Mailer.Test/obj/Debug/Mvc.Mailer.Test.pdbhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-50(0)
  • D Mvc.Mailer.Test/obj/Debug/ResolveAssemblyReference.cachehttps://github.com/smsohan/MvcMailer/pull/81/files#diff-51(0)
  • D Mvc.Mailer.Test/obj/Release/DesignTimeResolveAssemblyReferencesInput.cachehttps://github.com/smsohan/MvcMailer/pull/81/files#diff-52(0)
  • D Mvc.Mailer.Test/obj/Release/Mvc.Mailer.Test.csproj.FileListAbsolute.txthttps://github.com/smsohan/MvcMailer/pull/81/files#diff-53(15)
  • D Mvc.Mailer.Test/obj/Release/Mvc.Mailer.Test.dllhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-54(0)
  • D Mvc.Mailer.Test/obj/Release/Mvc.Mailer.Test.pdbhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-55(0)
  • D Mvc.Mailer.Test/obj/Release/ResolveAssemblyReference.cachehttps://github.com/smsohan/MvcMailer/pull/81/files#diff-56(0)
  • A Mvc.Mailer.Test/packages.confighttps://github.com/smsohan/MvcMailer/pull/81/files#diff-57(5)
  • A Mvc.Mailer.gpStatehttps://github.com/smsohan/MvcMailer/pull/81/files#diff-58(4)
  • R Mvc.Mailer.slnhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-59(65)
  • M Mvc.Mailer/EmptyHttpContext.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-60(30)
  • M Mvc.Mailer/ExtensionMethods/HtmlHelperExtensions.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-61(41)
  • D Mvc.Mailer/ExtensionMethods/MailMessageExtensions.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-62(59)
  • M Mvc.Mailer/ExtensionMethods/UrlHelperExtensions.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-63(91)
  • M Mvc.Mailer/ILinkedResourceProvider.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-64(42)
  • A Mvc.Mailer/IPostProcessor.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-65(7)
  • M Mvc.Mailer/ISmtpClient.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-66(27)
  • M Mvc.Mailer/LinkedResourceProvider.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-67(77)
  • M Mvc.Mailer/MailerBase.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-68(685)
  • M Mvc.Mailer/Mvc.Mailer.csprojhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-69(215)
  • A Mvc.Mailer/MvcMailMessage.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-70(44)
  • M Mvc.Mailer/NuGet/MvcMailer.nuspechttps://github.com/smsohan/MvcMailer/pull/81/files#diff-71(36)
  • A Mvc.Mailer/NuGet/input/lib/40/Fizzler.Systems.HtmlAgilityPack.dllhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-72(0)
  • A Mvc.Mailer/NuGet/input/lib/40/Fizzler.dllhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-73(0)
  • A Mvc.Mailer/NuGet/input/lib/40/HtmlAgilityPack.dllhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-74(0)
  • M Mvc.Mailer/NuGet/input/lib/40/Mvc.Mailer.dllhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-75(0)
  • A Mvc.Mailer/NuGet/input/lib/40/PreMailer.Net.dllhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-76(0)
  • A Mvc.Mailer/NuGet/input/lib/40/nunit.framework.dllhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-77(0)
  • M Mvc.Mailer/NuGet/input/tools/cs/IMailerMethodTemplate.cs.t4https://github.com/smsohan/MvcMailer/pull/81/files#diff-78(3)
  • M Mvc.Mailer/NuGet/input/tools/cs/IMailerTemplate.cs.t4https://github.com/smsohan/MvcMailer/pull/81/files#diff-79(15)
  • M Mvc.Mailer/NuGet/input/tools/cs/MailerMethodTemplate.cs.t4https://github.com/smsohan/MvcMailer/pull/81/files#diff-80(18)
  • M Mvc.Mailer/NuGet/input/tools/cs/MailerTemplate.cs.t4https://github.com/smsohan/MvcMailer/pull/81/files#diff-81(29)
  • M Mvc.Mailer/NuGet/output/MvcMailer.1.2.nupkghttps://github.com/smsohan/MvcMailer/pull/81/files#diff-82(0)
  • M Mvc.Mailer/SmtpClientBase.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-83(57)
  • M Mvc.Mailer/SmtpClientWrapper.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-84(98)
  • M Mvc.Mailer/StringResult.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-85(146)
  • M Mvc.Mailer/TestSmtpClient.cshttps://github.com/smsohan/MvcMailer/pull/81/files#diff-86(84)
  • D Mvc.Mailer/bin/Debug/Mvc.Mailer.dllhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-87(0)
  • D Mvc.Mailer/bin/Debug/Mvc.Mailer.pdbhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-88(0)
  • D Mvc.Mailer/bin/Debug/content/Views/web.config.transformhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-89(19)
  • D Mvc.Mailer/bin/Debug/content/web.config.transformhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-90(18)
  • D Mvc.Mailer/bin/Release/Mvc.Mailer.dllhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-91(0)
  • D Mvc.Mailer/bin/Release/Mvc.Mailer.pdbhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-92(0)
  • D Mvc.Mailer/bin/Release/content/Views/web.config.transformhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-93(19)
  • D Mvc.Mailer/bin/Release/content/web.config.transformhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-94(23)
  • D Mvc.Mailer/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cachehttps://github.com/smsohan/MvcMailer/pull/81/files#diff-95(0)
  • D Mvc.Mailer/obj/Debug/Mvc.Mailer.csproj.FileListAbsolute.txthttps://github.com/smsohan/MvcMailer/pull/81/files#diff-96(7)
  • D Mvc.Mailer/obj/Debug/Mvc.Mailer.dllhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-97(0)
  • D Mvc.Mailer/obj/Debug/Mvc.Mailer.pdbhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-98(0)
  • D Mvc.Mailer/obj/Debug/ResolveAssemblyReference.cachehttps://github.com/smsohan/MvcMailer/pull/81/files#diff-99(0)
  • D Mvc.Mailer/obj/Release/DesignTimeResolveAssemblyReferencesInput.cachehttps://github.com/smsohan/MvcMailer/pull/81/files#diff-100(0)
  • D Mvc.Mailer/obj/Release/Mvc.Mailer.csproj.FileListAbsolute.txthttps://github.com/smsohan/MvcMailer/pull/81/files#diff-101(7)
  • D Mvc.Mailer/obj/Release/Mvc.Mailer.dllhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-102(0)
  • D Mvc.Mailer/obj/Release/Mvc.Mailer.pdbhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-103(0)
  • D Mvc.Mailer/obj/Release/ResolveAssemblyReference.cachehttps://github.com/smsohan/MvcMailer/pull/81/files#diff-104(0)
  • A MvcMailer.gpStatehttps://github.com/smsohan/MvcMailer/pull/81/files#diff-105(4)
  • D MvcMailer.suohttps://github.com/smsohan/MvcMailer/pull/81/files#diff-106(0)
  • M README.markdownhttps://github.com/smsohan/MvcMailer/pull/81/files#diff-107(33)

Patch Links:

  • https://github.com/smsohan/MvcMailer/pull/81.patch
  • https://github.com/smsohan/MvcMailer/pull/81.diff

smsohan avatar Feb 02 '13 18:02 smsohan

Don't worry, take ur time.

hernangm avatar Feb 04 '13 16:02 hernangm

Bump. I am planning manually including this fork into my project. However it would be great if you could merge this pull request in to the official nuget package. To ease maintainability etc.

Cheers:D

darcythomas avatar Jan 13 '14 20:01 darcythomas

Is this dead?

sheam avatar Jun 21 '15 04:06 sheam