Where to Put CSS in mandrill template - css

I was using mandrill for sending mails . Using mandrill template functionality, i have properly coded on server side to send the mails. I am receiving the mails, but CSS is not properly rendered. In my code i have set inline_CSS = 'true'. Also, in Mandrill in settings-> sending options i have set 'Inline CSS Styles In HTML Emails' = true. But still when i design a template its not rendered properly in 'preview and test' and also if send via API.
In Addition to this, i need to know how to add CSS file to your template dir. OR how to give the link to this CSS file. Because doing the settings is ok, but there should be some place where i need to put that file or pass it some way.

Mail clients cannot load style content from an externally-linked stylesheet. There is no local file path/system, so all style must be included within the template itself, between <style> tags.

Related

How to prevent an asset css file from caching in a custom BE module?

I've found this line of code to embed custom css in my custom BE module extension.
<f:asset.css identifier="myextcss" href="EXT:myExt/Resources/Public/Css/myext.css" />
This works fine. But the browser caches this file - how do I prevent it from this? I know, that pages can be set non-cache in FE. But in BE I want only this file prevented from caching, not the whole module.
after some trying I found a workaround.
I add these lines to my controller
$mytoken = substr (str_shuffle($_GET['token']),0,8);
$this->view->assign('mytoken', $mytoken);
And this to my fluid:
<f:asset.css identifier="myextcss" href="EXT:myExt/Resources/Public/Css/myext.css?{mytoken}" />
So the browser find always a "new" file request and reload it.

User agent stylesheet setting script code to display none

Trying to get a code generated by Crowdriff to display a gallery on a page and it is being blocked with css that I am not defining as display none. I'm not sure where this is coming from as I haven't set it anywhere to display none.
Screenshot of problem
Here is the page where it should be showing:
https://www.orillialakecountry.ca/test-gallery/
Script tags are never displayed. These are used to import and execute javascript files.
In the javascript a HTML element is probably targeted in which it tries to inject it's HTML.

Read CSS content from bundle in code in an ASP.NET MVC website

I have a website, that uses bootstrap and a bootstrap theme. My website also sends out notification emails to users of the website when they trigger certain actions.
I want the body of a notification email that is sent out to be nicely formatted HTML content with the same look and feel as the main website.
I've always been taught to write DRY code, and make things as maintainable as possible, so I want to include the same bootstrap CSS that my website uses as an embedded file in the email, and have the HTML body reference that CSS, so that if I decide to change the theme of my website, it automatically re-styles my notification emails.
I'm using System.Net.Mail.SmtpClient to send the email, and adding content using AlternateViews. I don't want to include a live reference back to my site's css incase the email is viewed offline, so I want to embed the css.
I'm stuck with how to read the CSS file into a string, and attach it to the email. In my BundleConfig, I have this:
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap-sandstone.css",
"~/Content/site.css"));
So I tried:
var css = File.ReadAllText(HttpContext.Current.Server.MapPath("~/Content/css"));
But as I thought might happen, it threw a FileNotFound exception.
What can I use that will let me pass in ~/Content/css and out pops the css?
I found a way to grab the CSS content using this code:
var cssBundle = BundleTable.Bundles.GetBundleFor("~/Content/css");
var css = cssBundle.GenerateBundleResponse(new BundleContext(new HttpContextWrapper(HttpContext.Current), BundleTable.Bundles, string.Empty)).Content;
However, as mason predicted (in the comments) the CSS doesn't work in the email, and it's far too large, so I'm going to simply embed basic CSS in the HTML.

External css not working in Broadleaf Email Templates

I am using a custom email template in broadleaf. In that I am unable to use external css file.It's only allowing inline css. Is it will function like that or Is i am doing anything wrong.
This is how i am referring my css file
Both are not working.Kindly Have your say on this friends.
Most likely the email client will block external links and therefore your mail will not appear as you think it should. So its better you write the inline css for emailer.

How to attach html file so that gmail's "view" option works

I have a script that sends an email with an html attachment. When I select "view" in gmail I get text...however when I click on "download" instead of "view", then open it, it displays as it should.
I think it's gmail related because I observe the exact same behavior from IE, FireFox(win/linux), Chrome(win/linux)
I made a youtube video of here:
http://www.youtube.com/watch?v=WkGyxcFQXS8
Am I doing something wrong?
Thanks
Not all email clients support the <style> tag. Gmail is one of those; it only respects in-line styling.
If your code is producing the css & html, then you could change it to use in-line styles for the table.
If you want something more auto-magic, see How do I use Google Apps Script to change a CSS page to one with inline styles?.
One way around this would be to have your script simply host the HTML file somewhere, and email a link to that file.
I cannot find any documentation from Google or the GMail team, but I would be surprised if they allowed HTML attachments to be opened and viewed (this would be a security risk, since they would essentially allow their email servers to host user-generated web content).

Resources