新手问题,试图找出是否已发送电子邮件并显示结果,似乎无法使其正常工作。
function SendPreview() {
var value = CKEDITOR.instances['Source'].getData();
alert(value);
var model = { EmailBody: value.toString(), EmailTo: $("#SendTo").val(), EmailSubject: $("#Subject").val() };
var request = $.ajax({
url: '/Campaign/SendPreviewEmail',
async: false,
type: 'POST',
dataType: 'JSON',
data: { model: JSON.stringify(model) },
cache: false,
success: function (data) {
if (data) {
alert("Message Sent");
} else {
alert("Message Not Sent, Please check details");
}
}
});
}
[HttpPost]
[ValidateInput(false)]
public bool SendPreviewEmail(string model)
{
var e = new EmailPreview();
JavaScriptSerializer objJavascript = new JavaScriptSerializer();
e = objJavascript.Deserialize<EmailPreview>(model);
if (!string.IsNullOrEmpty(e.EmailTo) && !string.IsNullOrEmpty(e.EmailSubject) && !string.IsNullOrEmpty(e.EmailBody))
{
if (IsValidEmail(e.EmailTo))
{
_mailService.SendMail(account.Email, e.EmailTo, e.EmailSubject, e.EmailBody, true);
return true;
}
}
return false;
}