blue
blue

Reputation: 588

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]");
            });
        }
    }
}

Upvotes: 3

Views: 1832

Answers (2)

Steven Quick
Steven Quick

Reputation: 519

The package and version of MvcMailer needed depends on both the the MVC and the .NET version you are using:

ASP.NET MVC3

Install-Package MvcMailer3

ASP.NET MVC4 with .NET 4

Install-Package MvcMailer -Version 4.0

ASP.NET MVC4 with .NET 4.5

Install-Package MvcMailer

This will likely change again when MVC5 and .NET 5 come out.

Upvotes: 5

blue
blue

Reputation: 588

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/

Upvotes: 0

Related Questions