...

View Full Version : Mailto help



bobm5
10-21-2006, 08:26 AM
Hi All,

I'm not sure if this is the correct forum for this, but I'm having some trouble with an email form i've created for work. It uses a simple html form with various fields, and some javascript code to format the data entered.

Here's some of the code:

<script language="JavaScript">
<!--
function createMail(form)
{
var data = document.dataForm

form.action = "mailto:me@me.com?subject=" + encodeURI("IWR - Due ") + encodeURI(data.dtReqd.value) + encodeURI(" - ") + encodeURI(data.ProjCd.value) + "&body=" + encodeURI("\n\n" + data.Comments.value + "\n")

return true;
}

// -->
</script>


<form
name="mailForm"
action="mailto:me@me.com"
method="post"
enctype="multipart/form-data"
onSubmit="return createMail(this)">


When I run this form on my PC (in IE or firefox) it opens a new compose screen in my email client (thunderbird), and I can send the email with no problems. On some other computers I've tried it on it doesn't open a compose screen at all and just sends the email in the background. That would be ok I guess but the email received is not formatted properly, i.e. spaces are replaced by %20 and the bulk of the email is in an attachment named postdata.att. I can't figure out why this happens on some PC's and not on others. They're all running windows XP and using thunderbird as the mail client.

Is there possibly some windows setting for the mailto command?

Thanks
Bob

_Aerospace_Eng_
10-21-2006, 08:35 AM
I belive your enctype should be text/plain instead.

felgall
10-21-2006, 11:00 PM
Using mailto: with forms produces inconsistent results in different browsers.

Some will send the form directly.
Some will open the eassociated email program and ignore the form content completely.
If there is no email program then the form will be completely non-functional. (Internet cafes, libraries etc will normally only allow web access and not email).

Either use mailto: in a link or use a server side form2mail script to send the form if you want something that will work properly in all browsers.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum