Skip to content Skip to sidebar Skip to footer

Send A Web Page Through Javascript

I want to email a web page through javascript. Its enough to open the outlook new mail option. I try to move a Here i am using mailto: option in html. Actually i am try to create a

Solution 1:

Javascript can't send e-mails. Your best bet is the <a href="mailto:foo@bar.com">e-mail me</a> syntax. There is a convention that most browsers suppors that lets you set the contents of various attributes as well.

<a href="mailto:foo@bar.com?subject=Hi&body=hello%2C+there%21">e-mail me</a>

It will have to be URL encoded, and as far as I know, there is no reliable way to pass HTML. You have to assume plain text emails.

Solution 2:

You really need the server's help to make this easier.

1) Have the server make an XMLHTTP request to the page that generates the HTML you want. Grab it and make it the mail body.

  • or -

2) Grab the innerHTML, stick it in a hidden textarea and post it back to the server. Use the posted form field in the mail body.

Solution 3:

You need to do this server-side, not client side. Outlook is not going to allow you the control you need to use a template. And for good reason - you wouldn't want websites taking control over your Outlook and sending emails.

If you can tell us what server you're using, we can show you how to send the email server-side.

Solution 4:

There are security restrictions which stop it working directly. Yes if you wanted Outlook specifically, you could start messing with ActiveX - but that is fiddly and limited certain operating systems , installations, and security settings.

It is much better to use a mailto: URL. This is then cross-platform, and supports any default mail client.

Post a Comment for "Send A Web Page Through Javascript"