Sathish
Sathish

Reputation: 799

How to open an email automatically on the page load

I'd like to open an email automatically with To & subject, when the html page loads. I need to use only mailto functionality. Can someone help me how to do this?

Upvotes: 3

Views: 5595

Answers (2)

srini
srini

Reputation: 884

try something like this

      <html>
       <head>

       <script type="text/javascript">
        function mymessage()
        {
         location.href = "mailto:[email protected]?subject=Hello";

         }
        </script>
    </head>

    <body onload="mymessage()">
    </body>

     </html>

Upvotes: 2

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324820

Redirect the user to a mailto link. This can be done with basic JavaScript:

location.href = "mailto:[email protected]?subject=Test+Message";

Just take into consideration the fact that:

  1. A lot of people use online email these days (GMail, hotmail, etc) - not me personally, but... other people.
  2. If the user has a desktop email program, you'll be forcing an unexpected window open on them.
  3. It's even worse if the user has a desktop email program, but has never set it up - as would be the case of most of the people in point 1. The window would open and then the whole "email setup" process would start.

Just be careful.

Upvotes: 9

Related Questions