Sending emails using MvcMailer

MK Web UG

MK Web UG
Macedonian Web User Group

Hajan's Blog - MKDOT.NET

Dedicated to Microsoft .NET Technologies

Sending emails using MvcMailer

  • Comments 2

MvcMailer is an interesting component that you can use for sending emails in ASP.NET MVC Framework. The very great thing is that it uses Razor view engine views as email templates and is pretty easy to setup and use. In this article you will see how to install it, setup email templates and send emails…

1. INSTALLATION

- First of all, create new ASP.NET MVC project (or use one you are already developing…)

- The next thing is to install the component. The component can be installed using NuGet Package Manager (PowerShell console or NuGet Packages Dialog) or you can get the source code directly from the Github repository here.

Installing using NuGet Package Manager

If you want to install it using NuGet Packages Manager Dialog, you can find it on Visual Studio.NET 2010 in Tools –> Library Package Manager –> Manage NuGet Packages…

and then search for MvcMailer

By clicking Install, the NuGet will do all the job for you.

On the other hand (as I always prefer to do), if you use NuGet PowerShell Console, just run the following command:

Once you run the command, following log in the console has been generated in my side:

PM> Install-Package MvcMailer
Attempting to resolve dependency 'T4Scaffolding (≥ 0.9.7)'.
Attempting to resolve dependency 'EntityFramework (≥ 4.1.10311.0)'.
You are downloading EntityFramework from Microsoft, the license agreement to which is available at http://go.microsoft.com/fwlink/?LinkId=224682. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'EntityFramework 4.1.10715.0'.
Successfully installed 'T4Scaffolding 0.9.9'.
Successfully installed 'MvcMailer 1.1'.
Successfully removed 'EntityFramework 4.1.10331.0' from MyMvcMailer.
Successfully added 'EntityFramework 4.1.10715.0' to MyMvcMailer.
Successfully added 'T4Scaffolding 0.9.9' to MyMvcMailer.
Successfully added 'MvcMailer 1.1' to MyMvcMailer.

NuGet will add MvcMailer.dll to your solution and you are done with installation.

This blog post is re-posted from my asp.net official weblog (http://weblogs.asp.net/hajan)

CONTINUE READING

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • I am using MvcMailer with my website to send html emails. seems good, but im just wondering how i can view the created emails in a browser?

  • @Einstein, by created emails... do you mean the email templates / the email you've sent to your users in form of newsletter or something similar??? If so, then you can do that only by adding specific Controller that will be used to serve the view through the mvc default routing mechanism... For instance, if you have NewsletterMailer views folder, you can add controller NewsletterMailerController which will have actions for the corresponding view templates... This is one of many other possible ways...

    Hope this helps...

    Hajan