Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scaffold Mailer error.... #37

Closed
andrewknightley opened this issue Jan 24, 2012 · 10 comments
Closed

Scaffold Mailer error.... #37

andrewknightley opened this issue Jan 24, 2012 · 10 comments

Comments

@andrewknightley
Copy link

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

  • Scaffold <<<< Mailer UserMailer PasswordReset, PasswordNew
    • CategoryInfo : InvalidArgument: (:) [Invoke-Scaffolder], ParameterBindingException
    • FullyQualifiedErrorId : PositionalParameterNotFound,T4Scaffolding.Cmdlets.InvokeScaffolderCmdlet

Thanks in advance

@andrewknightley
Copy link
Author

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
Copy link

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
Copy link

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
Copy link

Leftyx commented Aug 31, 2012

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

@alexjamesbrown
Copy link

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

@mehrad-rafigh
Copy link

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

@nan3co
Copy link

nan3co commented Oct 11, 2013

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

@ZaibiMohammed
Copy link

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

@Kizmar
Copy link

Kizmar commented Jul 8, 2014

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
Copy link

kewur commented Sep 23, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants