I understand you do not have access to ViewBag/ViewData, which is probably related that you have a WebAPI context (and not MVC). But why don't you just instantiate the mailer and pass parameters?
[RoutePrefix("api/foo")]
public class FooController : ApiController
{
[HttpPost]
[Route("bar")]
public void Bar(string foo, string bar)
{
MyMailer myMailer = new MyMailer();
myMailer.MyAction(foo, bar).Send();
}
}
Then:
public class MyMailer : MailerBase, IMyMailer
{
public virtual MvcMailMessage MyAction(string foo, string bar)
{
ViewBag.Foo = foo;
ViewBag.Bar = bar;
// Populate ...
}
}
I know it's not optimal but that's what I ended up doing and it works fine. Would that help?