Я относительно новичок в написании сценариев, поэтому, пожалуйста, расскажите мне, если я делаю глупые ошибки. Мне было предложено создать скрипт, который принимает значения из формы и файлов, введенных пользователем. Затем у вас есть кнопка отправки, которая открывает почтовое приложение по умолчанию на компьютере клиента и заполняет тело электронной почты значениями, полученными из формы структурированным образом.Создайте форму, которая использует 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>
Большое вам спасибо за отзыв, я искренне благодарен. Можно ли использовать другой способ, чтобы вся эта информация отображалась в почтовом приложении по умолчанию, включая вложения? –
@AminaRingim: Никто, о котором я знаю. –
отлично! Спасибо огромное! –