Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Action: mailto

Status
Not open for further replies.

perryair

IS-IT--Management
Apr 7, 2005
91
0
0
IL
Hi All,
I developed html form that post the data to e-mail,
I would like to set the subject as %textbox1%
for example: the subject will be one of the text boxes from my form..

Is that possible?

P.S
This is an offline file, no cgi-bin or any web engine.
 
Code:
<form onSubmit="SendToEmail(this)">
  ...
</form>

Use javascript to parse the form elements and put together a standard mailto URL
Code:
  $url = "";
  $url += "mailto:";
  $url += $target;
  $url += "?subject=";
  $url += $subject;
  $url += "&body=";
  $url += $emailbody;
  
  window.location = $url;

<marc>
 
Thanks but I can't understand.. can you please paste the java code as well..? or just send an example for the entire code.

Thanks..
 
cLFlaVA said:
manarth, aren't you getting JavaScript and PHP a little crossed?
Not for the first time ;)
Or indeed the last...

However (apart from the $ signs preceding each variable) the code is valid.

<marc>
 
See below:

<html dir="ltr">

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Simple Form</title>
</head>

<body>

<table border="0" width="100%" id="table1">
<tr>
<td>
<form method="POST" name="myform" action="mailto:mymail@mydomain.com?subject=MY SUBJECT" enctype="text/plain">
<table border="0" width="100%" id="table2">
<tr>
<td width="106">First Name</td>
<td><input type="text" name="f_name" size="20"></td>
</tr>
<tr>
<td width="106">Last Name</td>
<td><input type="text" name="l_name" size="20"></td>
</tr>
</table>
<p>&nbsp;</p>
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
</td>
</tr>
</table>

</body>

</html>
 
Hi,
you should use as METHOD "GET", and the "subject" should be the name of one of the input fields
Code:
<html dir="ltr">

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Simple Form</title>
</head>

<body>

<table border="0" width="100%" id="table1">
    <tr>
        <td>
        <form method="GET" name="myform" action="mailto:mymail@mydomain.com" enctype="text/plain">
            <table border="0" width="100%" id="table2">
                <tr>
                    <td width="106">Subject</td>
                    <td><input type="text" name="subject" size="100"></td>
                </tr>
                <tr>
                    <td width="106">First Name</td>
                    <td><input type="text" name="f_name" size="20"></td>
                </tr>
                <tr>
                    <td width="106">Last Name</td>
                    <td><input type="text" name="l_name" size="20"></td>
                </tr>
                
            </table>
            <p>&nbsp;</p>
            <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
        </form>
        </td>
    </tr>
</table>

</body>

</html>

___
____
 
I prefer to send it as "text/plain" and just to change the subject as per one of the text boxes.

any idea?
 
actually I have to post it since this is an e-form.
 
Marc, any idea in regard to your code above.. how can I just send it as "POST" since there is a data that need to be send by "text/plain" format in the body.

Thanks..
 
perryair said:
in regard to your code above.. how can I just send it as "POST"

Simply put, you can't. POST requests are to change something on a server. POST is not intended to generate anything client side.

As this is all taking place client side, the only recognised format will be generating a (GET) URI of the following form:
Code:
mailto:[COLOR=red][ignore]email_address@example.com[/ignore][/color]?subject=[COLOR=red]subject_line[/color]&body=[COLOR=red]body_text[/color]

The 3 variables are email address, subject, and email contents (body).

As you're processing this client-side, you have to use a GET request. Simply use javascript to grok the correct 3 variables (email address, subject, email body) from the form data, then 'window.location' to the appropriate URI,

<marc>
 
I am confused by this thread, but in the event that this might be helpful I am including some code as a basis for introducing the ability to take the subject from a text box.

The code as it stands allows you to paste some data into the textarea and then send it to an email address. Some text is pre-pasted as an example.

Code:
<html><head><title>Tubularity - eREPORT</title></head>
<body bgcolor="yellow"><div align="center">
<b>TO:employer@work.com
&nbsp;&nbsp;&nbsp;&nbsp;SUBJECT:
Expenses
</b><form method="POST"
action="mailto:
employer@work.com
?subject=
Expenses
"enctype="text/plain" target=_blank>
<textarea name="Data" rows="20"
cols="80" readonly>


          EMPLOYEE:  CliveC                           DATE: 19990821
          ------------------------------------------------------------

                                   EXPENSES

                      Sun 19990815 110 Taxi          22.00
                      Sun 19990815 220 Dinner        12.00
                      Sun 19990815 800 Lodging      109.91
                      Mon 19990816 200 Breakfast      6.22
                      Mon 19990816 210 Lunch          5.50
                      Mon 19990816 220 Dinner        36.49
                      Mon 19990816 310 Telephone     13.28
                      Mon 19990816 800 Lodging      109.91
                      Tue 19990817 200 Breakfast      6.20
                      Tue 19990817 210 Lunch          5.48
                      Tue 19990817 220 Dinner        35.95
                      Tue 19990817 310 Telephone      5.28
                      Tue 19990817 310 Telephone      6.70
                      Tue 19990817 800 Lodging      109.91
                      Wed 19990818 200 Breakfast      6.80
                      Wed 19990818 210 Lunch          6.67
                      Wed 19990818 220 Dinner        12.50
                      Wed 19990818 310 Telephone      6.42
                      Wed 19990818 310 Telephone      5.20
                      Wed 19990818 900 Car Rental   153.08
                      Wed 19990818 110 Taxi          22.00
                                       TOTAL        697.50
</textarea><br><br><b>
<input type="submit" value="Submit">

</b></form></body></html>

Clive
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top