I am a beginner in MVC. I want to develop an action method in MVC which fires Mailto:?body=body goes here.&subject=test subject
and so the default mail client will automatically populate the email for the user. Right now I have List<String>
which contain mailto:
urls.
Please, if you have any experience or demo code it will be helpful to me. Thanks in advance.
I am a beginner in MVC. I want to develop an action method in MVC which fires Mailto:?body=body goes here.&subject=test subject
and so the default mail client will automatically populate the email for the user. Right now I have List<String>
which contain mailto:
urls.
Please, if you have any experience or demo code it will be helpful to me. Thanks in advance.
Share Improve this question edited Sep 16, 2014 at 20:31 mhu 18.1k10 gold badges65 silver badges94 bronze badges asked Jul 3, 2013 at 10:21 SurajSuraj 3951 gold badge3 silver badges12 bronze badges 3- What does action method mean? Is this in a particular framework or just raw JavaScript? – Chris Calo Commented Jul 4, 2013 at 2:34
- ASP.NET MVC applications is organized around controllers and action methods. The controller defines action methods. Controllers can include as many action methods as needed. Action methods typically have a one-to-one mapping with user interactions. Examples of user interactions include entering a URL into the browser, clicking a link, and submitting a form. Each of these user interactions causes a request to be sent to the server. In each case, the URL of the request includes information that the MVC framework uses to invoke an action method. – Suraj Commented Jul 4, 2013 at 8:36
- 1 Consider adding the asp tag and/or mentioning this in your question. – Chris Calo Commented Jul 4, 2013 at 11:45
2 Answers
Reset to default 10try this :
window.location.href = "mailto:[email protected]";
with body
window.location.href = "mailto:[email protected]?body=yourBody";
Event with jquery
$('button').on('click', function(){
window.location.href = "mailto:[email protected]?body=yourBody";
});
My ActionMethod
[HttpPost]
public JsonResult emailTemplate()
{
List<String> str = new List<String>();
str.Add("Mailto:?body=Hello1&subject=test subject1");
str.Add("Mailto:?body=Hello2&subject=test subject2");
return Json(str);
}
JavaScript Function in view
function SendMailClicked() {
$.ajax({
type: "POST",
url: "/Home/emailTemplate",
//data: "{'ReviewComponentIds':'1,2,3'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
jQuery.each(response, function () {
window.location.href = this + '\n';
});
},
failure: function (errMsg) {
alert('failure');
}
});
}