Ravi Shankar B Ravi Shankar B - 2 years ago 242
Javascript Question

sending email from Angular.js web application

I am newbie to AngularJS. In one of my web application using Angular.js I need to confirm password by sending emails to the concern person. How can I achieve this in Angular.js please guide me. I am a .NET guy. I am using Visual Studio 2013.


Answer Source

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;
                return true;

and ajax call as

        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;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download