0

My requirement is to send the content of the page through mail on click of a button.when the user will click on the the send mail button then entire content of the page within the form tag should be sent to the mail mentioned by me. I am trying the following but didnt work:

function fnSendMail()
{ 
   
   var link = "mailto:me@example.com"
             + "?cc=myCCaddress@example.com"
             + "&subject=" + encodeURIComponent("This is my subject")
             + "&body=" + encodeURIComponent(document.getElementById("colMain").innerHTML);
    //alert(link);
    window.location.href = link;


}

ColMain is the id of the main div withing which content will be there. The above code is breaking at the last line. Can any one please help me out for teh same. Thanks in advance!!

Raj
  • 204
  • 1
  • 3
  • 12
  • http://jsfiddle.net/m11m31c3/ seems to work fine for me.may be because of something in html content ofColMain div.can you post the error you are getting.or update fiddle with your colMain content – Deshan Jan 28 '15 at 09:43
  • error:The data area passed to a system call is too small. – Raj Jan 28 '15 at 10:00
  • I have tried with some other div id then in that case it is sending the corrosponding html code instead of the layout – Raj Jan 28 '15 at 10:07
  • Looks like this error is browser and email client specific.check this. http://stackoverflow.com/questions/13191015/the-data-area-passed-to-a-system-call-is-too-small – Deshan Jan 29 '15 at 06:59
  • http://stackoverflow.com/questions/5620324/mailto-with-html-body According to this you cannot send HTMl in mail body this way.You may have to move the mail code to server side if you want to send HTML – Deshan Jan 29 '15 at 07:59

0 Answers0