
Below is the complete code of the EmailController. Simply pass that HTML as your email body.

After that write the Mjml syntax for your email template and call the “Render” method of the Mjml service. Inject “MjmlServices” through the constructor and create a HttpGet method by the name “Send” which returns Ok in case of successful email send. We have successfully created the Mjml service now it’s time to inject it into our controller. Applications and plugins The MJML App (MJML is included) Visual Studio Code plugin (MJML is included) Atom plugin (MJML needs to be installed separately). For this purpose, write the below code in your “ConfigureServices” method in the startup.cs class and also add namespace “using Mjml.AspNetCore”. You can use dependency injection which will make it much easier to use Mjml Services. Write MJML in the browse tab and install the latest stable version of Mjml.AspNetCore package.Īfter installing the package add the namespace of “using Mjml.AspNetCore” in EmailController. After creating the EmailController right-click on your project and click on manage NuGet packages. Name the controller as “EmailController”. Right-click on the Controller folder and add a new empty MVC Controller. There will be a few folders and files in the project already. It will take few seconds and your project will be created. Select target framework as 3.1 and click on Create. Stepsįirst of all open visual studio and click on create a new project. Gulp plugin - Allows you to use your engine to render HTML if you have custom components linked. Sublime Text Plugin Simply highlights MJML code. Visual Studio Code plugin Ability to send emails with Nodemailer or Mailjet. We will simply pass it to our email body and it will be rendered in our email. Atom Plugin Includes error-spotting and a live preview feature like the MJML app. Then we will write the MJML syntax for our email template and then we will call the “Render” method of the MJML Service which returns the HTML. The only thing we do in our API is to add the NuGet package of MJML. The abstraction it offers ensures you stay up-to-date with industry practice and responsiveness.

MJML is designed with responsiveness in mind.

Creating a responsive email is much easier with tags like, , and. Say get rid of the endless HTML table or email client email. Make your speed and productivity enhanced with MJML semantic syntax. MJML sums up everything Mailjet has learned about HTML email creation over the past few years and includes a whole layer of complexity related to responsive email creation. People with basic knowledge of C# and ASP.Net Core Web API through the NuGet package. In this article, you will learn how to integrate Mailjet Markup Language (MJML) in your ASP.
