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
585 stars 176 forks source link

Send email from WebApi project where ViewBag is not available #131

Open DmitryEfimenko opened 10 years ago

DmitryEfimenko commented 10 years ago

Please see this question on StackOverflow

Any help is appreciated.

DmitryEfimenko commented 10 years ago

Not to be annoying, but even a general guidance would be greatly appreciated. Am I on the right track by guessing that LinkedResources has something to do with the solution to my problem? If so, how would I access them in the view given that neither ViewBag nor ViewData are available there? Only object PageData is available there.

var res = new Dictionary<string, string>();
res.Add("name", "David");
return Populate(x =>
{  
    x.LinkedResources = res;
    x.ViewName = "Welcome";
    x.To.Add(email);
    x.Subject = "Welcome";
});