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

I am creating a pdf by converting my html file to pdf using jsPDFvar doc = new jsPDF();var specialEleme

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745132083a4613021.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信