Tuesday 7 June 2016

Open outlook on button click in jQuery

Open outlook on button click in jQuery

 

 

If you want to send an email on button click instead of hyperlink, you have use window.location. You can also put subject and body text in email. It is very easy onle onle line code like this.
window.location = 'mailto:nirbhay.ni@gmail.com?subject=TestSubject&body=TestBody';
In this section I have also given an example to send mail with hyperlink.
Note: you can send formeted html in body.
CODE
<!DOCTYPE html>
<html>
<head>
  <title>jQuery With Example</title>
  <script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
  <script type="text/javascript">
    $(function () {
      $('.btnSendEmail').click(function (event) {
        var email = 'nirbhay.ni@gmail.com';
        var subject = 'Jquery With Example';
        var emailBody = 'Hi Nirbhay';
        window.location = 'mailto:' + email + '?subject=' + subject + '&body=' + emailBody;
      });
    });
  </script>
</head>
<body>
   <div>
    <button class="btnSendEmail">Send Email</button><br /><br />
    <a href="mailto:nirbhay.ni@gmail.com?subject=YourSubject&body=Test Body">Mail Me</a>
  </div>
</body>
</html>
DISPLAY


Mail Me

 

5 comments:

  1. Thanks for the good words! Really appreciated. Great post. I’ve been commenting a lot on a few blogs recently, but I hadn’t thought about my approach until you brought it up. 

    Selenium training in Chennai

    Selenium training in Bangalore

    ReplyDelete
  2. I found your blog while searching for the updates, I am happy to be here. Very useful content and also easily understandable providing..
    Believe me I did wrote an post about tutorials for beginners with reference of your blog. 




    Selenium training in bangalore
    Selenium training in Chennai
    Selenium training in Bangalore
    Selenium training in Pune
    Selenium Online training

    ReplyDelete
  3. Thanks for the good words! Really appreciated. Great post. I’ve been commenting a lot on a few blogs recently, but I hadn’t thought about my approach until you brought it up.
    hardware and networking training in chennai

    hardware and networking training in omr

    xamarin training in chennai

    xamarin training in omr

    ios training in chennai

    ios training in omr

    iot training in chennai

    iot training in omr

    ReplyDelete
  4. .I just recently discovered your blog and have now scrolled through the entire thing several times. I am very impressed and inspired by your skill and creativity, and your "style" is very much in line with mine. I hope you keep blogging and sharing your design idea

    hadoop training in chennai

    hadoop training in velachery

    salesforce training in chennai

    salesforce training in velachery

    c and c plus plus course in chennai

    c and c plus plus course in velachery

    machine learning training in chennai

    machine learning training in velachery

    ReplyDelete