Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Mailto help

  1. #1
    New to the CF scene
    Join Date
    Oct 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Mailto help

    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

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    I belive your enctype should be text/plain instead.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,472
    Thanks
    0
    Thanked 634 Times in 624 Posts
    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.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •