Embed CSS in Email JSP template | Community
Skip to main content
trench999
Level 4
October 16, 2015
Solved

Embed CSS in Email JSP template

  • October 16, 2015
  • 3 replies
  • 1012 views

It is best practice to place styles inline and in the <head> for an HTML email to cover the most clients.  As we add components to an email, how can we inject styles into the <head> of the email being developed.  If we simply include the clientLibs we get a linked resources so that doesn't work.  Someone mentioned inputStream.  Is that the best way and if so, can someone point us to an example of this?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Feike_Visser1

Look at the code here:

https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/master/bundle/src/main/java/com/adobe/acs/commons/rewriter/impl/VersionedClientlibsTransformerFactory.java

This code shows you how to read the content of a clientlib, check this line: htmlLibrary.getInputStream()

This you can use to write some custom code around it.

3 replies

smacdonald2008
Level 10
October 16, 2015

Most AEM developers use ClientLibs to handle CSS - as discussed in this official AEM documentation:

http://docs.adobe.com/docs/en/cq/current/developing/clientlibs.html

Why are you opposed to using Clientlibs in an AEM solution? 

trench999
trench999Author
Level 4
October 16, 2015

We are using clientLibs extensively of course, but emails need "inline" styles in the element tags and in the head and not linked libs.

Feike_Visser1
Adobe Employee
Feike_Visser1Adobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

Look at the code here:

https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/master/bundle/src/main/java/com/adobe/acs/commons/rewriter/impl/VersionedClientlibsTransformerFactory.java

This code shows you how to read the content of a clientlib, check this line: htmlLibrary.getInputStream()

This you can use to write some custom code around it.