Tuesday, September 24, 2013

Javascript Launch compose new email on button click

Hi Folks,
In this post we are going to see, how to launch compose new email page of your default mail client.
Below is the javascript which will do the trick. You just need to call this function on onclick property of the button present in your webpage.
In this example we will be adding the body of the mail as "{document url}" and subject as "My Subject"
Here we go..

<script type="text/javascript">
function mailThisMsg()
{
var recpt = ""
var subj = "My Subject"
var text = encodeURIComponent(document.URL)
var bcc = ""
var content = new Array()  
content[0] = "mailto:"
content[1] = recpt
content[2] = "?subject="
content[3] = subj
content[4] = "&body="
content[5] = text
content[6] = "&bcc="
content[7] = bcc
content = content.join("")
window.location = content
}
</script>


Hope this helps...

No comments:

Post a Comment

Popular Posts