[英]How to attach a generated pdf to a smtpjs mail in javascript
I am creating a pdf by converting my html file to pdf using jsPDF我正在通过使用 jsPDF 将我的 html 文件转换为 pdf 来创建 pdf
var doc = new jsPDF();
var specialElementHandlers = {
'#fav-items': function (element, renderer) {
return true;
}
};
$('#submit').click(function () {
doc.fromHTML($('#fav-items').html(), 15, 15, {
'width': 170,
'elementHandlers': specialElementHandlers
});
var pdfBase64 = doc.output('datauristring');
I am then sending an email using the smtpjs.然后我使用 smtpjs 发送电子邮件。 The email is sent successfull but couldnt attach the pdf file.
电子邮件已成功发送,但无法附加 pdf 文件。 Please guide me through this.
请指导我完成这个。
The code to send the email发送电子邮件的代码
Email.send({
Host: "smtp.gmail.com",
Username : "abc@gmail.com",
Password : "abc",
To : receiver,
From : "abc@gmail.com",
Subject : emailSubject,
Body : emailBody,
Attachments : [
{
}]
}).then(
)
});
Email.send({
Host: "smtp.gmail.com",
Username : "abc@gmail.com",
Password : "abc",
To : receiver,
From : "abc@gmail.com",
Subject : emailSubject,
Body : emailBody,
Attachments : [
{
name : list.pdf
data : pdfBase64
}]
}).then(
)
});
This worked !这奏效了! The created pdf got added to the email as an attachment
创建的 pdf 作为附件添加到电子邮件中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.