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 KumarRank #91 · 22.9K reputationPosted Sep 12, 2020, 7:12 AM EDT
Jignesh KumarRank #91 · 22.9K reputationPosted Sep 12, 2020, 1:13 AM EDT
Posted Sep 12, 2020, 2:16 AM EDT
Jignesh Kumar i have changes this.But not working
Jignesh KumarRank #91 · 22.9K reputationPosted Sep 12, 2020, 2:26 AM EDT
Posted Sep 12, 2020, 2:31 AM EDT
sanaullah sanaullah48 reputationPosted Sep 12, 2020, 2:59 AM EDT
Posted Sep 12, 2020, 4:32 AM EDT
sanaullah sanaullah not working .
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts