2016-06-18 7 views
0

私はスクリプト作成には比較的新しいので、間違っていると私と一緒に裸にしてください。私はフォームとユーザーが入力したファイルから値をとるスクリプトを作成するように求められました。クライアントのコンピュータ上でデフォルトのメールアプリケーションを開き、電子メール本体に構造化された方法でフォームから取得した値を入力する送信ボタンがあります。JavaScriptを使用してデフォルトのメールアプリケーションを開いてファイルを添付するフォームを作成する

私は、ユーザーがアップロードしたファイルを除き、すべてデフォルトのメールアプリケーションに添付する以外のやり方を作成することができました。 私はインターネット上のあらゆる場所を検索しましたが、私は運がありません!誰かがこれを完璧にするのを助けてくれますか?私は今、ほぼ3週間失われている!

以下は、私は、フォームを含む、書かれている全体のコードです:

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

答えて

1

あなたがそれを行うことができない私は99.999%確信しています。受信者、件名、特定のヘッダー、本文を設定できますが、添付ファイルは設定できません。たとえば、the RFC for the mailto: protocolに添付ファイルは何もありません。この例では「ファイル」という単語が記述されている唯一の場所は編集エラーで、ファイルの添付とは関係ありません。

+0

本当にありがとう、私は本当に感謝しています。この情報を添付ファイルを含むデフォルトのメールアプリケーションに表示するために私が使用できる別の方法はありますか? –

+0

@AminaRingim:私が知っていることはありません。 –

+0

素晴らしい!どうもありがとうございます! –

関連する問題