new_user
new_user

Reputation: 355

Nodemailer - how add attachment to template email in jade

I don't know how use embedded images in email, utilizing attachments.

I have in .js:

var mailOptions = { ... html: 'my html jade', attachments: [{ filename: 'image.png', path: '/picture/file', cid: 'myPicture' //same cid value as in the html img src }]

In jade file:

... img(src="cid:myPicture")

When i send my email .... This not work. I have added attachment in the e-mail, but message do not have embedded images.

Upvotes: 0

Views: 697

Answers (1)

Daniel Bidulock
Daniel Bidulock

Reputation: 2354

Whoa! Super old question. You've either figured it out or quit programming by now. When I ran into the same problem, Google led me here.

It all comes down to the path. I had to set the absolute path including the file name. So, in your case, it would all look like this:

var mailOptions = {
  // ...
  html: 'my html jade',
  attachments: [{
  filename: 'image.png',
  path: '/picture/file/image.png',
  cid: 'myPicture' //same cid value as in the html img src
}]

I can't speak for the jade stuff, but hopefully this will help some other Nodemailer.

Upvotes: 1

Related Questions