Click here to Skip to main content
15,900,511 members
Please Sign up or sign in to vote.
1.40/5 (3 votes)
See more:
Is it possible to send Mail using javascript. If yes then kindly give me some hint.
Posted
Updated 13-Jul-18 1:38am
Comments
Nitij 13-Jun-16 6:02am    
You can't. Server needs to come into picture to provide authentication details.

JavaScript is of course client based so doesn't have the capabilities as say C# on the server. To send email, without calling some server-side code, you are basically limited to mailto
 
Share this answer
 
You can see this here[^]. It uses Javascript but sends email using Outlook automation.
 
Share this answer
 
NO! JavaScript can’t email a form! but, there are alternatives to send the form data to an email address.

See detail here:
http://www.javascript-coder.com/javascript-form/javascript-email-form.phtml[^]
 
Share this answer
 
You could create a web service that sends a mail...

C#
[WebMethod]
public void SendEmail(string subject, string message)
{
     // Standard C# Send Mail stuff    
}


Then, you could call the web service from script to send the mail.

Have a look at jquery or other scripting frameworks which provide AJAX helper functionality for calling web service methods
 
Share this answer
 
XML
<form method="post" action="">
    <input type="text" id="email" name="name" required>
    <input type="button" value="Send Email" onclick="send()/>
</form>



XML
<script type="text/javascript">
  function send() {
    var link = 'mailto:email@example.com?subject=Message from '
             +document.getElementById('email').value
             +'&body='+document.getElementById('email').value;
    window.location.href = link;
}
</script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900