homepage Welcome to WebmasterWorld Guest from 54.235.61.62
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
Prompting for a Subject using Mailto
rahmuss




msg:4414308
 9:13 pm on Feb 4, 2012 (gmt 0)

Is there a way to prompt for a subject when using the mailto?

I am using <form> in html. I do not have access the the server, so I cannot use a .cgi or .pl file or anything like that.

This is just for five people. The html file will not be online, it will be on located on each of their computers.


<HTML>
<FORM action="mailto:myfirstemail@whatever.com, mysecondemail@whatever.com?Subject=" method="post" enctype="text/plain">
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="4", width="900">
<TR>
<TD align=right><B>Name: </B></TD>
<TD><INPUT type="text" name="Name " size="100"></TD>
</TR>
<TR>
<TD></TD>
<TD>First Name, Last Name</BR></BR></TD>
</TR>
<TR>
<TD align=right><B>Complaint: </B></TD>
<TD><TEXTAREA name="Complaint " cols="76" wrap="virtual" rows="6"></TEXTAREA></BR>(Provide details of the complaint)</TD>
</TR>
<TR>
<TD><INPUT type="submit" name="submit" value="Send"> <INPUT type="reset" name="reset" value="Clear">
</TABLE>
</FORM>
</HTML>

 

Marshall




msg:4414318
 9:55 pm on Feb 4, 2012 (gmt 0)

You could use JavaScript with an onsubmit check form function.

Marshall

rahmuss




msg:4414412
 4:20 am on Feb 5, 2012 (gmt 0)

Will the Javascript allow me to do a form which will allow the entered data to be sent via email with whatever subject they want to enter? I've been trying to get it to do that; but haven't been successful yet.

Staffa




msg:4414451
 11:47 am on Feb 5, 2012 (gmt 0)

Since your form is for use by only five people why not hard code Subject="whatever", so that they know that the email comes from one of the other four people, and add an extra row in your table where they can specify the real subject

londrum




msg:4414452
 11:54 am on Feb 5, 2012 (gmt 0)

cant you just change the form from POST to GET, and add a new input field with the name 'subject'
you'll have to remove the bit in the form's url where you've already put 'subject'

i think you'll have to send the message content as part of the URL as well, so you'll have to change the textarea's name to 'body'

its been a long time since i used mailto so i might be wrong

if its not online then you dont have to worry about spam

piatkow




msg:4414638
 9:46 am on Feb 6, 2012 (gmt 0)

I haven't looked at this for many years but I have a feeling that there are browser compatibility issues over trying to use a form to input to a mailto.

Alternative solutions:
1. If you are using an external host check if they provide access to a formmail script, some do and some don't so its worth asking. (For example my ISP gives me a free site, html only but with a formmail script as well)
2. There are a number of third party service providers who will give you free form processing at the expense of having an ad displayed.

rahmuss




msg:4414769
 5:34 pm on Feb 6, 2012 (gmt 0)

Staffa,
Since your form is for use by only five people why not hard code Subject="whatever", so that they know that the email comes from one of the other four people, and add an extra row in your table where they can specify the real subject

I can't make it "whatever" (or anything static) because the subject will include the name as well as the date. Your second option, to add an extra row I can do; but how do I get it to use that input data as the subject? I guess that's what I'm confused about.

londrum,
cant you just change the form from POST to GET, and add a new input field with the name 'subject'
you'll have to remove the bit in the form's url where you've already put 'subject'

i think you'll have to send the message content as part of the URL as well, so you'll have to change the textarea's name to 'body'

I can add a new input field for Subject. I don't really understand how changing the method to POST will help, though I really don't understand POST very well. And if I name the field "body" will that automatically make the "&body" part be what they entered?

Marshall




msg:4414813
 7:21 pm on Feb 6, 2012 (gmt 0)

This is a script I have seen used in web pages. Not sure if/how you could adapt it for your purpose.

<!-- Begin

function isPPC() {

if (navigator.appVersion.indexOf("PPC") != -1) return true;

else return false;

}

if(isPPC()) {

document.write('A HREF=\"mailto:\?subject\=Take a look at this page I found, ' + document.title + '?body=You can see this page at: ' + window.location + '\" OnMouseOver="status=\' \'; return true;" TITLE="Send your friends an e-mail about this page">Email this page to a friend<\/A>');

}

else { document.write('<A HREF=\"mailto:\?body\=Take a look at this page I found, ' + document.title + '. You can see this page at: ' + window.location + '\" OnMouseOver="status=\' \'; return true;" TITLE="Send your friends an e-mail about this page">Email this page to a friend<\/A>');

}

// End -->

</script>

Marshall

rahmuss




msg:4415228
 11:11 pm on Feb 7, 2012 (gmt 0)

Seems like this should be easy to do. Like I should be able to have a field for something which I give the name of "Subj" and then when I submit it with the input button, or maybe in the Form tag I can set the Subject=Subj, and have it done. Why does it have to be so complicated?

Marshall




msg:4415230
 11:28 pm on Feb 7, 2012 (gmt 0)

If it was easy, you would have no reason to meet all the wonderful people on WebmasterWorld :)

Let us know if you get something to work.

Marshall

londrum




msg:4415385
 10:00 am on Feb 8, 2012 (gmt 0)

have a look at this, this is close to what you want. it populates the name, subject and message with whatever they've written

the only thing is this... it turns every space into a plus sign. if you can figure out a way around that then you're sorted

<HTML>
<FORM action="mailto:myfirstemail@whatever.com,mysecondemail@whatever.com" method="get" enctype="text/plain">
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="4", width="900">
<TR>
<TD align=right><B>Name: </B></TD>
<TD><INPUT type="text" name="Name " size="100"></TD>
</TR>
<TR>
<TD></TD>
<TD>First Name, Last Name</BR></BR></TD>
</TR>
<TR>
<TD align=right><B>Subject: </B></TD>
<TD><INPUT type="text" name="subject" value="">
</TR>
<TR>
<TD align=right><B>Complaint: </B></TD>
<TD><TEXTAREA name="body" cols="76" wrap="virtual" rows="6"></TEXTAREA></BR>(Provide details of the complaint)</TD>
</TR>
<TR>
<TD><INPUT type="submit" name="submit" value="Send"> <INPUT type="reset" name="reset" value="Clear">
</TABLE>
</FORM>
</HTML>
Marshall




msg:4415485
 4:06 pm on Feb 8, 2012 (gmt 0)

londrum,

I tried that out (was curious). Works really well. Good job. :)

Marshall

rahmuss




msg:4415711
 4:38 am on Feb 9, 2012 (gmt 0)

Wow, londrum, I think this might actually work. It works for me here at home, so I'll have to try it at work. You Rock!

rahmuss




msg:4415728
 5:40 am on Feb 9, 2012 (gmt 0)

Not sure why it won't let me edit my post. I just wanted to note that I don't see any "+" signs. Although I also don't see the name anywhere, so maybe it's not quite fixed; but it's a lot further than I've come so far. Thanks again.

Marshall




msg:4415741
 6:40 am on Feb 9, 2012 (gmt 0)

I just wanted to note that I don't see any "+" signs.

Neither did I.

Although I also don't see the name anywhere

I will reiterate, it worked fine for me, no problems.

Marshall

rahmuss




msg:4415947
 4:27 pm on Feb 9, 2012 (gmt 0)

Oh, now I see the "+" signs here at work using Outlook. So it must be mail client preference or something. Before, at home, I was using Gmail.

I found that there are three values for the enctype and that w3schools defines them as follows:
application/x-www-form-urlencoded - Default. All characters are encoded before sent (spaces are converted to "+" symbols, and special characters are converted to ASCII HEX values)

multipart/form-data - No characters are encoded. This value is required when you are using forms that have a file upload control

text/plain - Spaces are converted to "+" symbols, but no special characters are encoded

So it seems the first and third will definitely put the "+" symbol for spaces; but the second one doesn't say that, though when I use it, it seems to do the same thing (ie. puts the "+" symbols for spaces).

londrum




msg:4415991
 5:58 pm on Feb 9, 2012 (gmt 0)

i just had a little look on the web and i dont think there's anyway around it. its normal for a mailto URL to convert spaces into safe characters like '+'. some mail programs will then convert them back into spaces and some wont. i guess that is one of the disadvantages of using mailto

londrum




msg:4416058
 9:01 pm on Feb 9, 2012 (gmt 0)

... try changing
method="get" to method="post". it looks like you get rid of the + signs doing it that way... but unfortunately you get something else in return
rahmuss




msg:4416305
 4:23 pm on Feb 10, 2012 (gmt 0)


<html>
<body>
<form name="call" method="post" enctype="text/plain">
Request: <input id="request">
<script type="text/javascript">
var text = document.getElementById("request").value;
var email = "myemail@hotmail.com";

var subject = "Thanks";

document.call.action = "mailto:"+email+"?subject="+subject;
</script>
</br>
<input type="submit" value="Submit">
</form>
</body>
</html>

So, this sends the email and puts the subject of: Thanks


<html>
<body>
<form name="call" method="post" enctype="text/plain">
Request: <input id="request">
<script type="text/javascript">
var text = document.getElementById("request").value;
var email = "myemail@hotmail.com";

var subject = "Thanks"+text;

document.call.action = "mailto:"+email+"?subject="+subject;
</script>
</br>
<input type="submit" value="Submit">
</form>
</body>
</html>

This also sends the email; but with the same subject: Thanks
Instead of Thanks (and then whatever the entered value is). Both emails submit the entered value (text) into the body just fine. Is it ignoring the variable "text"? Or is it blank still, grabbing the blank value before it processes what the value is?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved