Tag Archives: css

C# send a mail using razor views as template

If you are looking for a way to send an e-mail via C#, you may find some code examples such as Send e-mail via SMTP using C#. I used such a solution in many projects, by creating an HTML file in a separate folder, reading its contents, do text replacements and then send the message. That solution always worked fine. I liked my old school solution also because I could edit the HTML file and preview it by clicking it or pointing the browser to its location.

Lately I found a more elegant solution for my MVC projects with a library called Postal. You can install it via NuGet, create a view containing your email template, then, in your controller, you can send a mail just with a few lines of code, as explained in the Getting Started example.

At work I coded a few mailers (to send a reminder, or an occasional newsletter) and they worked quite fast with my old school system. Also with Postal, results have been quite good.

If you are interested in performance, I can code a few tests to see how much each solution can scale. Updates will come, stay tuned.

By the way, if you are interested in creating responsive emails, you may have a look at Bootstrap Template for HTML Email and if you want to convert an existing HTML into a mail friendly HTML (all CSS styles inline), check Premailer.

Bootstrap 3 add size between xs 480 and sm 768

If you, like me, were relying on bootstrap 3 for creating a responsive website and trying to style your elements in your grid, so that they look nice also between xs (480px) and sm (768px) you would have noticed that there are no col-* classes that support this particular case.

I googled and found a suggestion for improvement to add a new class called sm in bootstrap3. Sadly, the suggestion was ignored and if you need to make your website look good for window sizes between 480px and 768px you must implement the feature yourself, or use what the community (andyl in this case) is offering you.

Conclusion: if you need this feature, read the discussion I linked above and build bootstrap using the LESS or SASS scripts linked there. If you are still new to bootstrap, less, sass etc. the fastest way is to include andyl’s bootstrap_ms.css (with my update).

Just include it after the main bootstrap file, like this:

<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/bootstrap_ms.css" />