faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

58 of 70 people (83%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

JavaScript: Is there a way of passing parameters to the subject or body line of an email?

Apr 7th, 2008 23:12
ha mo, Knud van Eeden, Keith M,


----------------------------------------------------------------------
--- Knud van Eeden --- 21 January 2004 - 06:41 pm --------------------
JavaScript: E-mail: Parameter: Is there way of passing parameters to
subject or body of an email?
---
To get the idea, type this in the URL field of your browser
(this will open your currently active e-mail client,
e.g. Microsoft outlook, or Yahoo compose mail, ...)
javascript:window.open("mailto:[email protected]?
[email protected]&Subject=test&Body=test");
where:
e-mail address(es) is the text after 'mailto:'
and
cc address(es) is the text after '?Cc='
and
subject text is the text after '&Subject='
and
body text is the text after '&Body='
---
If you want to use pure HTML, use
(save this e.g. as
  myexamp1.htm
  and load this file in your browser
)
--- cut here: begin --------------------------------------------------
 <HTML>
  <HEAD>
   <TITLE>
     e-mail example
   </TITLE>
  </HEAD>
  <BODY>
    <A HREF="mailto:[email protected]?
[email protected]&Subject=test&Body=test"> Send an e-mail </A>
  </BODY>
 </HTML>
--- cut here: end ----------------------------------------------------
---
If you want to include it in a JavaScript method, include the line:
 window.open( "mailto:[email protected]?
[email protected]&Subject=test&Body=test" );
---
to use parameters include something like
(save this text for example as
  myexamp.htm
 and load this file in your browser):
--- cut here: begin --------------------------------------------------
<HTML>
 <BODY
   onLoad=' PROCEmailRun
( "[email protected]", "[email protected],[email protected]
2.com,[email protected]", "test", "Hi,%0A%0AHow are
you doing?%0A%0A%0Awith friendly greetings,%0A<your name>" );'
 >
 </BODY>
</HTML>
<!-- library: e-mail: send [kn, ri, tu, 18-09-2001 01:40:52] -->
<SCRIPT LANGUAGE = "JavaScript">
<!--
// function PROCEmailRun( myemailS, myccS, mysubjecttextS,
mybodytextS ) {
 // e.g. <HTML>
 // e.g.  <BODY
 // e.g.    onLoad=' PROCEmailRun
( "[email protected]", "[email protected],[email protected]
2.com,[email protected]", "test", "Hi,%0A%0AHow are
you doing?%0A%0A%0Awith friendly greetings,%0A<your name>" );'
 // e.g.  >
 // e.g.  </BODY>
 // e.g. </HTML>
 var mailtoS = "mailto:" + myemailS + "?Cc=" + myccS + "&Subject=" +
mysubjecttextS + "&Body=" + mybodytextS;
 window.open( mailtoS );
}
// -->
</SCRIPT>
--- cut here: end ----------------------------------------------------
---
---
PS
new line in the body: add %0A
comma in the body: add %2C
space in the body: add %20
(or more generally %<the ASCII hex code for that character>)
in the bodytext parameter.
---
---
Internet: see also:
---
How can I use checkboxes to designate the recipients of a form and
have it sent using the forms ACTION=mailto function
http://www.faqts.com/knowledge_base/view.phtml/aid/7305/fid/53
----------------------------------------------------------------------
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com