从AngularJS Web应用程序发送电子邮件 [英] Sending email from an AngularJS web application

查看:93
本文介绍了从AngularJS Web应用程序发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的一个AngularJS网络应用程序中,我需要通过向相关人员发送电子邮件来确认密码。我怎样才能在AngularJS中实现这一目标?我是一个.NET人,我正在使用Visual Studio 2013。

In one of my AngularJS web applications, I need to confirm a password by sending emails to a concerned person. How can I achieve this in AngularJS? I am a .NET guy and I am using Visual Studio 2013.

推荐答案

我通过网络服务实现了请参考代码片段下面

I have achieved through web services Please refer the code snippet below

public bool EmailNotification()
    {
            using (var mail = new MailMessage(emailFrom, "test.test.com"))
            {
                string body = "Your message : [Ipaddress]/Views/ForgotPassword.html";
                mail.Subject = "Forgot password";
                mail.Body = body;
                mail.IsBodyHtml = false;
                var smtp = new SmtpClient();
                smtp.Host = "smtp.gmail.com";
                smtp.EnableSsl = true;
                smtp.UseDefaultCredentials = false;
                smtp.Credentials = new NetworkCredential(emailFrom, emailPwd);
                smtp.Port = 587;
                smtp.Send(mail);
                return true;
            }
    }

和ajax调用

 $.ajax({
        type: "POST",
        url: "Service.asmx/EmailNotification",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (data)
        {

        },
        error: function (XHR, errStatus, errorThrown) {
            var err = JSON.parse(XHR.responseText);
            errorMessage = err.Message;
            alert(errorMessage);
        }
    });

这篇关于从AngularJS Web应用程序发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆