最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

smtp - How to attach a generated pdf to a smtpjs mail in javascript - Stack Overflow

programmeradmin2浏览0评论

I am creating a pdf by converting my html file to pdf using jsPDF

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. The email is sent successfull but couldnt attach the pdf file. Please guide me through this.

The code to send the email

Email.send({
Host: "smtp.gmail",
Username : "[email protected]",
Password : "abc",
To : receiver,
From : "[email protected]",
Subject : emailSubject,
Body : emailBody,
Attachments : [
  {

  }]
}).then(
)
});

I am creating a pdf by converting my html file to pdf using jsPDF

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. The email is sent successfull but couldnt attach the pdf file. Please guide me through this.

The code to send the email

Email.send({
Host: "smtp.gmail.",
Username : "[email protected]",
Password : "abc",
To : receiver,
From : "[email protected]",
Subject : emailSubject,
Body : emailBody,
Attachments : [
  {

  }]
}).then(
)
});
Share Improve this question edited Apr 21, 2021 at 20:15 Linda Paiste 42.4k8 gold badges80 silver badges116 bronze badges asked Dec 17, 2019 at 18:29 shagi.Gshagi.G 1511 gold badge2 silver badges10 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3
     Email.send({
     Host: "smtp.gmail.",
     Username : "[email protected]",
     Password : "abc",
     To : receiver,
     From : "[email protected]",
     Subject : emailSubject,
     Body : emailBody,
     Attachments : [
     {
      name : list.pdf
      data : pdfBase64 

     }]
     }).then(
     )
     });

This worked ! The created pdf got added to the email as an attachment

发布评论

评论列表(0)

  1. 暂无评论