繁体   English   中英

创建一个使用javascript打开默认邮件应用程序并附加文件的表单

[英]Create a form that uses javascript to open default mail application and attach files

我被要求创建一个脚本,该脚本从用户输入的表单和文件中获取值。 然后,它具有一个提交按钮,该按钮可打开客户端计算机上的默认邮件应用程序,并以结构化方式使用从表单中检索的值填充电子邮件正文。

我已经能够创建某种形式的表格,除了接收用户上传的文件并将其附加到默认的邮件应用程序外,它几乎可以完成所有其他工作。 我在互联网上到处搜索,没有运气! 有人可以帮我完善一下吗。 我迷路了近三个星期!

以下是我编写的完整代码,包括以下形式:

 <script type="text/javascript"> function update_message_body() { var file = document.input_form.file.value; var awb = document.input_form.awb.value; var dtsnr = document.input_form.dtsnr.value; var incoterms = document.input_form.incoterms.value; var TypeOfGoods = document.input_form.ToG.value; var DescriptionOfGoods = document.input_form.DoG.value; var quantity = document.input_form.quantity.value; var UnitMeasure = document.input_form.um.value; var ValueOfGoods = document.input_form.VoG.value; var TotalWeight = document.input_form.tw.value; var ClearingAgent = document.input_form.ca.value; var DEtoCA = document.input_form.DEtoCA.value; var CDUNHRD = document.input_form.CDUNHRD.value; document.proxy_form.Information.value = "\\n" + "\\n" + "This email is to inform you of the details acquired from new record :" + "\\n" + "\\t Uploaded Attachment :" + file + "\\n" + "\\t AWB :" + awb + "\\n" + "\\t Date and time shipping notification recieved :" + dtsnr + "\\n" + "\\t Incoterms :" + incoterms + "\\n" + "\\t Types of Goods :" + TypeOfGoods + "\\n" + "\\t Description of Goods :" + DescriptionOfGoods + "\\n" + "\\t Quantity :" + quantity + "\\n" + "\\t Unit Measure :" + UnitMeasure + "\\n" + "\\t Value of Goods :" + ValueOfGoods + "\\n" + "\\t Total Weight :" + TotalWeight + "\\n" + "\\t Clearing Agent :" + ClearingAgent + "\\n" + "\\t DE set to Clearing Agent :" + DEtoCA + "\\n" + "\\t When cargo is delivered to UNHRD :" + CDUNHRD + "\\n" + "\\n" + "\\n" + "\\n" + "Sincerely,\\n"; } < /script> 
 <style> .dotted { border-style: dotted; padding-top: 30px; padding-right: 30px; padding-bottom: 30px; padding-left: 30px; } </style> 
 <!DOCTYPE html> <html> <body> <form name="input_form"> <table class="dotted"> <tr> <td>Attachment: <input type="file" name="file" maxlength=50 allow="file_extension"> </td> </tr> <tr> <td>AWB: <input name="awb" type="text" pattern="[0-9]{9}" required> </td> </tr> <tr> <td>Date and time shipping notification recieved: <input name="dtsnr" type="datetime-local" required> </td> </tr> <tr> <td> Incoterms: <select name="incoterms" required> <option>CIF</option> <option>DAP</option> <option>ABC</option> <option>DEF</option> <option>GHI</option> <option>JKL</option> </select> </td> </tr> <tr> <td> Types of Goods: <select name="ToG"> <option>Biscuit</option> <option>Tent</option> <option>Car</option> <option>Medical Kit</option> </select> </td> </tr> <tr> <td>Description of Goods: <input type="text" placeholder="Description of Goods" required name="DoG"> </td> </tr> <tr> <td>Quantity: <input type="text" pattern="{9}" name="quantity" required> </td> </tr> <tr> <td> Unit Measure: <select name="um" required> <option>EA</option> <option>BX</option> <option>Pallet</option> <option>20' container</option> <option>40' container</option> </select> </td> </tr> <tr> <td>Value of Goods: <input type="text" pattern="{9}" name="VoG" required> </td> </tr> <tr> <td>Total Weight: <input type="text" pattern="{9}" name="tw" required> </td> </tr> <tr> <td>Clearing Agent: <input type="text" name="ca" required> </td> </tr> <tr> <td>DE set to Clearing Agent: <input type="date" name="DEtoCA" required> </td> </tr> <tr> <td>When cargo is delivered to UNHRD: <input type="date" class="textbox" name="CDUNHRD" required> </td> </tr> </table> </form> <form name="proxy_form" method="post" enctype="text/plain" action="mailto:?subject=Inbound Form" onSubmit="return update_message_body();"> <input type=hidden name="Information"> <input type=submit value="send mail"> </form> </body> </html> 

我99.999%的人肯定不能这样做。 您可以设置收件人,主题,某些标题和正文,但不能设置附件。 例如, RFC中没有关于mailto: protocol的附件,并且唯一提及单词“ file”(在一个示例中)的地方似乎是编辑错误,与附加文件无关。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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