Hello,
I am developing custom JIRA plugin and I am facing issue with defining CSS in email template. The velocity template is rendered using VelocityManager.getEncodedBody(...) and the email is sent using EmailUtils.sendEmail(...). Everything works but e-mail is completely missing AUI CSS (despite elements are defined properly), #requireResources did not help. So I defined styles by myself and included them directly to template but it seems that 90% of styles are ignored (even very basic like 'border').. Is there any possibility how to render it correctly?
I will be very grateful for any help.
Markéta
Jira version: 7.13.1
E-mail server: hMailServer
E-mail client: Outlook
I've resolved the issue. CSS were not applied because mentioned methods modified templates (for example text is wrapped by <p></p> tags) so the most of selectors did not match elements anymore so it is not possible to use AUI for this. As workaround I've defined own CSS that was respecting changes in HTML and it works.
Hi Markéta
Can you give example as you did this?
Big thx.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Mikhail,
when your plugin parses .vm template and sends it as email, it is little bit modified so selectors that use 'direct children sign' (>) do not work anymore (in my case some elements were also missing classes that I added). So it is not possible to add AUI CSS in the standard way. When you open your email as HTML (you can save it in this format using mail client - Outlook in my case), you can see what was produced and how it was modified. Then you can adapt your CSS to this. I resolved it by adding own styles, respecting HTML changes, directly to template. You can basically use what you need from standard AUI and change selectors.
I know this solution is not elegant but it works..
Hope it helped.
Kind regards,
Markéta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Markéta,
I thought about it, but I thought there was some more elegant way.
You broke my dream. :)
In any case, thanks for confirming my guess.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Mikhail,
even standard email templates have their own styles included so I am afraid there is not better solution. I agree my solution is ugly, I am not very satisfied too, but decided to share it because it took me days of trying before finding a way how to include any styles.
If you found different solution, please share it, I would be very interested. :-)
Thanks and have a nice day!
Markéta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.