views:

766

answers:

1

What do I send as the owner for a MailDefinition.CreateMailMessage() sent through an ASP.Net MVC Controller?

//   owner:
//     The System.Web.UI.Control that owns this System.Web.UI.WebControls.MailDefinition.
public MailMessage CreateMailMessage(string recipients, IDictionary replacements, Control owner);

Edit: sending a new System.Web.UI.Control() seems to work ok. Is there a different/standard solution?

+1  A: 

I had the same problem as Adam after adapting the code described in system.web.ui.webcontrols.maildefinition

The solution is to replace "this" by "new System.Web.UI.Control()"

For example, in the C# Microsoft example above, instead of:

fileMsg = md.CreateMailMessage(sourceTo.Text, replacements, this);

In an MVC Controller you would write:

fileMsg = mailDefinition.CreateMailMessage("[email protected]", replacements, new System.Web.UI.Control());
Nadjib