
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. 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. We will simply pass it to our email body and it will be rendered in our email. 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.
Mjml tutorial how to#
In this article, you will learn how to integrate Mailjet Markup Language (MJML) in your ASP.
