www.webdeveloper.com
Results 1 to 7 of 7

Thread: mailto using email address from form field

  1. #1
    Join Date
    Jun 2010
    Posts
    4

    mailto using email address from form field

    Hi

    Please help!
    I have a form that i wish the entered fields to be emailed to 2 addresses; my address (bcc) and the email address that the user has entered in the email field on the form.

    Before you say it, i know that 'mailto' is not a recommended method but it the only one i can use (due to restrictions at work).

    below is the code i am using but it doesnt seem to like [document.forms.request.email.value].

    i know it works (including the validation) when i just enter an email address in the code but it doesnt using the email form field.

    what am i doing wrong!??


    many thanks in advance

    <FORM NAME='request'
    ACTION="mailto:[document.forms.request.email.value]?subject=Room Request&bcc=katymorgan@morleycollege.ac.uk"
    enctype="text/plain"
    METHOD= "POST" TARGET="_blank"
    onSubmit="return validateForm(request)">

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Code:
    <FORM NAME='request'
    ACTION="#"
    enctype="text/plain"
    METHOD= "POST" TARGET="_blank"
    onSubmit="validateForm(request); return false;">
    Code:
    function validateForm() {
    // validation
    // passed then:
    var f = document.forms.request;
    var q='Dear '+f.name.value+'&#37;0AYour '+f.comment.value+' in bla bla ...';
    f.action='mailto:'+f.email.value+'?bcc='+katymorgan@morleycollege.ac.uk+'&subject=FRoom Request&body=' + q;
    f.submit();
    }
    The user can still see the bcc and delete it.
    Perhaps a free service would be better.

  3. #3
    Join Date
    Jun 2010
    Posts
    4
    ah brilliant, thank you so much, you're a star!

  4. #4
    Join Date
    Jun 2010
    Posts
    4
    Thanks Fang for your help but is it possible to have a 'body' in the mailto as well as enctype="text/plain"?
    I can only get the body text to appear if i remove the enctype="text/plain".

  5. #5
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Explain 'body'?

  6. #6
    Join Date
    Jun 2010
    Posts
    4
    what i mean by 'body' is the body of the email i.e. the text in the email, or as in 'q' in the code you wrote, above.

    using enctype="text/plain" means the content of the form is in the message of the email (instead of as an attachment) however, ithink this stops the 'body' text being in the email aswell.

  7. #7
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    If you mean html then no.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles