0

(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!

Dan G
  • 51
  • 8
  • Please note that the destination email addresses are not hidden from the user and can therefore be used to deliver spam or other fake messages. So do not use personalized email addresses, use something more generic such as feedback@example.org. – ST-DDT Nov 06 '20 at 21:51

1 Answers1

0

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

Alexanderbira
  • 434
  • 3
  • 14