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.
Without any server-side code hosted on a server, you can send emails through your Angular application with smtpJS, a client-side Javascript library. First you need to download this library and include it into the necessary component of the Angular Application.
In this article, you will learn about AngularJS login form with ASP.NET. Learn to Create an empty MVC project, install Angular package, add Javascript Controllor, and add a Model class to the solution. As per you request, I am going to make a login page in AngularJS and ASP.
If you are writing an AngularJS front end web application, you may never have to use NodeJS. If you need tooling (build scripts to compile Sass, linters, etc) in your development or deployment process you can use NodeJS task runners like Gulp, Grunt or Webpack.
The mailto link is the easiest way to send an email from a front-end Javascript app. Put the email address you're sending to after mailto: as part of the string. When the user clicks on the anchor element, mailto will open the user's default email client and populate the “recipient” field with the intended email.
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;
}
}
and ajax call as
$.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);
}
});
you cannot send email via javascript library (angularjs or jquery and so on) you need server side for send mail best way for this case use ajax
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With