简体   繁体   中英

Is there a way to use JavaScript with the HTML to uplaod a file that attaches to an HTML-generated email?

(DISCLAIMER: I am very new to HTML/CSS/JavaScript, so apologies if my code is whacky)

I am looking for a way to generate an email with an email attachment. Here is my code:

<body>
  <form action="mailto:example3@example.com" method="GET">
    <label for="cc">Cc Line Addresses:</label>
    <br>
    <input id="cc" name="cc" type="email multiple" value="example1@example.com;example2@example.com"/>
    <br>
    <br>
    <label for="subject" >Enter your subject below:</label>
    <br>
    <input type="text" name="subject" id="subject">
    <br> 
    <br>
    <label for="body" >Enter the Email Body below:</label>
    <br><textarea id="body" name="body" rows="5" cols="50">Example body</textarea>
    <br>
    <br>
    <label for= "myFile">Click below to upload your attachment file</label>
    <!-- This is where I want the attachment to flow to the email-->
    <br>
    <br>
    <input type="file" id="myFile" name="attachment" class="fileUpload">
    <br>
    <br>
    <strong><label for="submit">Click Below to Generate New Email</label></strong>
    <br>
    <input type="submit" id="submit" value="Generate">
  </form>
</body>

I would like to use Javascript to have the uploaded file from the HTML form attach to the email generated by the submit button (opened with the default email client).

Thanks!

Try adding enctype="multipart/form-data" to your form element.
https://www.w3docs.com/snippets/html/how-to-create-mailto-forms.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM