It's me email send code in mvc but i have face issue .I have enter toEmail in textbox and body but here null value face issue)
public IActionResult SendEmail(string toEmail, string ToName, string from, string FromName, string Subject, string body)
{
try
{
string admin_email = "****";
string admin_emailpwd = "*****";
MailMessage mail = new MailMessage();
mail.To.Add(toEmail);
mail.From = new MailAddress(admin_email);
mail.Subject = Subject;
mail.Body = body;
mail.IsBodyHtml = true;
mail.Priority = MailPriority.Normal;
SmtpClient smtp = new SmtpClient();
smtp.Host = "mail.smtp2go.com";
smtp.Port = 2525;
smtp.UseDefaultCredentials = true;
smtp.Credentials = new System.Net.NetworkCredential(admin_email, admin_emailpwd);
smtp.EnableSsl = true;
smtp.Send(mail);
it's me html and jquery code .Jquery code get textbox value jquery code working fine.
Answer to the Query
@**@
$("#btnSend").click(function () {
debugger;
console.log("click");
var toEmail = $.trim($("#txtTo").val());
//var subject = $.trim($("[id*=txtSubject]").val());
var body = $.trim($("[id*=txtBody]").val());
$.ajax({
type: "POST",
url: "SendEmail",
data: "{ toEmail: '" + toEmail + "', body: '" + body + "' }",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
alert(r.d);
},
error: function (r) {
alert(r.responseText);
},
failure: function (r) {
alert(r.responseText);
}
});
return false;
});
});
Please check this
Jignesh KumarPosted Sep 12, 2020, 11:12 AM
Posted Sep 12, 2020, 8:32 AM
sanaullah sanaullah not working .
sanaullah sanaullahPosted Sep 12, 2020, 6:59 AM
Posted Sep 12, 2020, 6:31 AM
Jignesh KumarPosted Sep 12, 2020, 6:26 AM
Posted Sep 12, 2020, 6:16 AM
Jignesh Kumar i have changes this.But not working
Jignesh KumarPosted Sep 12, 2020, 5:13 AM