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

Issue using MVCMailer with webforms #46

Open
GeorgeJohn opened this issue May 8, 2012 · 5 comments
Open

Issue using MVCMailer with webforms #46

GeorgeJohn opened this issue May 8, 2012 · 5 comments

Comments

@GeorgeJohn
Copy link

Have an MVC project that uses a few webforms in it - we are in the process of converting them over. One of the pages happens to render a report. I'm trying to add the ability to email the report if the user wants to. When trying to use MvcMailer to achieve this it seems that it cannot find the view when I try to make the "PopulateBody" call

Here is my code from the UserMailer class

public class UserMailer : MailerBase, IUserMailer
{
///

/// Email Reports using this method
/// </summary>


/// <param name="toAddress">The address to send to.</param>
/// <param name="viewName">The name of the view.</param>
/// <returns>The mail message</returns>
public MailMessage SendReport(string toAddress, string viewName)
{
    var message = new MailMessage { Subject = "Report Mail" };
    message.To.Add(toAddress);
    ViewBag.Name = "Testing-123";

    this.PopulateBody(mailMessage: message, viewName: "SendReport");

    return message;
}

}

Every time I hit the populateBody call it responds with "Value cannot be null. Parameter name: routeData"

Any suggestions to overcome this would be quite helpful.

@smsohan
Copy link
Owner

smsohan commented May 8, 2012

Are you using is offline or on a background job? The MailerBase subclass
needs to be in a web project and need to run under a web server just like

your controllers.

Sohan
http://smsohan.com
skype:smsohan | gtalk:sohan39 | cell: 403-714-2673

On Tue, May 8, 2012 at 2:04 PM, GeorgeJohn <
reply@reply.github.com

wrote:

Have an MVC project that uses a few webforms in it - we are in the process
of converting them over. One of the pages happens to render a report. I'm
trying to add the ability to email the report if the user wants to. When
trying to use MvcMailer to achieve this it seems that it cannot find the
view when I try to make the "PopulateBody" call

Here is my code from the UserMailer class

public class UserMailer : MailerBase, IUserMailer
{
///

/// Email Reports using this method
///

/// The address to send to.
/// The name of the view.
/// The mail message
public MailMessage SendReport(string toAddress, string viewName)
{
var message = new MailMessage { Subject = "Report Mail" };
message.To.Add(toAddress);

   ViewBag.Name = "Testing-123";

   this.PopulateBody(mailMessage: message, viewName: "SendReport");

   return message;

}
}

Every time I hit the populateBody call it responds with "Value cannot be
null. Parameter name: routeData"

Any suggestions to overcome this would be quite helpful.


Reply to this email directly or view it on GitHub:
#46

@GeorgeJohn
Copy link
Author

No, not using it offline or on a background job. I have an aspx page that is creating my report for me that I want to attach to the mail. In there I call the SendReport method in the UserMailer. I can step through all the way to the PopulateBody method and there I get this error.

Mvc.Mailer is referenced in the web project. Are you suggesting that I need to add the actual MailerBase into my web project? Sorry just trying to clarify what you are suggesting.

@smsohan
Copy link
Owner

smsohan commented May 8, 2012

I will try to take a look at it tonight.

Sohan
http://smsohan.com
skype:smsohan | gtalk:sohan39 | cell: 403-714-2673

On Tue, May 8, 2012 at 3:56 PM, GeorgeJohn <
reply@reply.github.com

wrote:

No, not using it offline or on a background job. I have an aspx page that
is creating my report for me that I want to attach to the mail. In there I
call the SendReport method in the UserMailer. I can step through all the
way to the PopulateBody method and there I get this error.

Mvc.Mailer is referenced in the web project. Are you suggesting that I
need to add the actual MailerBase into my web project? Sorry just trying to
clarify what you are suggesting.


Reply to this email directly or view it on GitHub:
#46 (comment)

@GeorgeJohn
Copy link
Author

No worries. Thanks for the quick response. If it helps I also put together a test project where I just have a button on an aspx page and that in turn is just trying to call the welcome method in the UserMailer class. I get the same issue there as well. If you need me to zip up the project and send it to you I'd be more than happy to do so.

@GeorgeJohn
Copy link
Author

Were you ever able to look at this?

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

2 participants