javascript - 有没有办法使用带有 HTML 的 JavaScript 来上传附加到 HTML 生成的电子邮件的文件?
问题描述
(免责声明:我对 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
推荐阅读
- reactjs - 道具未定义,但我可以看到它在控制台记录道具
- asp.net - jwt 验证期间的 Asp.net 核心缓存 jwk
- sql - 使用集群的 hive 子查询优化
- r - 如何为股票代码列表上的调整收盘价编写一个 for 循环?
- reactjs - React-router - 将当前路由设置为最后一个路由
- javascript - Firebase 函数 - admin.messaging().sendToTopic 执行但从未进入 `then` 块
- ios - Xcode 中的 IOS MapKit 出错:在捆绑包 NSBundle 中找不到名为“Main”的故事板
- javascript - HTMLCollection [] 未定义
- java - 在 Java 中强制转换为时间戳
- php - WordPress 中的博客文章作者过滤器