问题描述
(免责声明:我是HTML / CSS / JavaScript的新手,如果我的代码很古怪,就此道歉)
我正在寻找一种生成带有电子邮件附件的电子邮件的方法。这是我的代码:
<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>
我想使用Javascript将HTML表单中的上传文件附加到“提交”按钮(使用默认电子邮件客户端打开)生成的电子邮件中。
谢谢!
解决方法
尝试将enctype="multipart/form-data"
添加到表单元素。
https://www.w3docs.com/snippets/html/how-to-create-mailto-forms.html