smsohan / MvcMailer

A Mailer for ASP.Net MVC that forms the Email Body using MVC Views (Razor etc.) following Ruby on Rails ActionMailer style
MIT License
584 stars 178 forks source link

Scaffold Mailer error.... #37

Closed andrewknightley closed 12 years ago

andrewknightley commented 12 years ago

When using the scaffold command I get the following error, I'm using on a fresh C# project with both web application and MVC 3.0

PM> Scaffold Mailer UserMailer PasswordReset, PasswordNew Invoke-Scaffolder : A positional parameter cannot be found that accepts argument 'UserMailer'. At line:1 char:9

Thanks in advance

andrewknightley commented 12 years ago

OK, just resolved this issue....

The problem is an out-of-date version of your scaffolding packages.

First of all you have to uninstall MvcScaffold and T4Scaffold packages with the Package Manager. Then (and this is the part most people with this problem are overseeing) remove the directories for these packages from the packages directory at solution level. MvcMailer.1.1 MvcScaffolding.1.0.6 T4Scaffolding.1.0.5

If you only remove the references to these packages at project level the fix doesn't work. This is the part that most online solutions miss out.

jasonwingfield commented 12 years ago

I got this to work by doing the following:

  1. If after removing & re-installing T4Scaffolding you still have an old version, use Tools | Library Package Manager | Manage NuGet Packages for Solution. Check for updates and apply for T4Scaffolding. This should bring you up to version 1.0.5.
  2. Use the correct PM command:

PM> Scaffold Mailer.Razor UserMailer Welcome,PasswordReset

This worked for me and the Mailer classes and views were properly generated.

tuntunwin commented 12 years ago

I removed MVCMailer and re-install MVCMailer and update the old T4Scafolding to latest version 1.0.6. But it still didn't work. So I did the following and it worked for me: 1.Uninstall MVCMailer (and T4Scafolding) 2.Install T4Scafolding (Install-Package T4Scafolding) 3.Install MVCMailer (Install-Package MVCMailer)

Leftyx commented 12 years ago

tuntunwin's solution worked for me after a Visual Studio restart.

alexjamesbrown commented 11 years ago

No matter what i do i just can't get this working, I ALWAYS get this error

mehrad-rafigh commented 11 years ago

I got the same issue here with the Visual Studio 2013 Ultimate Preview Edition. None of the workarounds is helping me :/

nan3co commented 10 years ago

I am geting the same issue with the Visual Studio 2013 Ultimate Preview Edition, any help?

ZaibiMohammed commented 10 years ago

the same case here, i tried all the solutions but still not working :(

Kizmar commented 10 years ago

Is there an example somewhere on github with a fresh scaffold or two so I can manually create them? I don't have time to mess with the scaffolding command issues, just need to see come code. ;)

kewur commented 8 years ago

hey, you don't actully need to use scaffolding to use mvcmailer. It just generates some code to make it easy on you.

To use MVCMailer create these classes (for example to send a verification email)

Create folder on root called "Mailers" Create class UsersMailer.cs

Under Views create folder "UsersMailer" Create view "_Layout.cshtml" Create View "VerifyEmail.cshtml"

on your Web.config add your usual settings:

< system.net> < mailSettings> < smtp from="bla@blabla.com"> < network enableSsl="true" host="smtp.blamailprovider.com" port="587" userName="bla@blabla.com" password="myrandompassword"/> < /smtp> < /mailSettings> < /system.net>

On your VerifyEmail.cshtml: < p> Test mail body < /p>

On your _Layout.cshtml: < html> < head>< /head> < body> @RenderBody() < /body> < /html>

Finally your UsersMailer.cs: public class UsersMailer : MailerBase { public UsersMailer() { MasterName = "_Layout"; } public virtual MvcMailMessage VerifyEmail() { return Populate(x => { x.Subject = "Test subject"; x.ViewName = "VerifyEmail"; x.To.Add("recipent@bla.com"l); }); }

}

After that just cal l new UsersMailer().VerifyEmail() from somewhere in your code.

that's it