Search code examples
asp.net-mvc-3mvcmailer

Error in "using Mvc.Mailer;"


I am trying to use MvcMailer for sending e-mail in my MVC3 Application.

I have successfully installed the package MvcMailer.

Used Reference Unable to install MvcMailer and followed the steps

But there is error while using it. using Mvc.Mailer; The type or namespace name 'MailerBase' could not be found (are you missing a using directive or an assembly reference?)

I am mentioning error as comment in below code.

using Mvc.Mailer;  //The type or namespace name 'Mvc' could not be found (are you missing a using directive or an assembly reference?)

namespace MvcApplicationMvcMailer.Mailers
{ 
    public class UserMailer : MailerBase, IUserMailer   //The type or namespace name 'MailerBase' could not be found (are you missing a using directive or an assembly reference?)
    {
        public UserMailer()
        {
            MasterName="_Layout";
        }

        public virtual MvcMailMessage Welcome()
        {
            //ViewBag.Data = someObject;
            return Populate(x =>
            {
                x.Subject = "Welcome";
                x.ViewName = "Welcome";
                x.To.Add("[email protected]");
            });
        }

        public virtual MvcMailMessage GoodBye()
        {
            //ViewBag.Data = someObject;
            return Populate(x =>
            {
                x.Subject = "GoodBye";
                x.ViewName = "GoodBye";
                x.To.Add("[email protected]");
            });
        }
    }
}

Solution

  • I got the solution. I needed to Install MvcMailer3. For MVC3 applications only.

    Got Solution from these link https://www.nuget.org/packages/MvcMailer https://www.nuget.org/packages/MvcMailer3/