'Show embedded picture using node (nodemailer)
I use nodemailer to send mail with a embedded picture,
var mailOption = {
html: 'Embedded image: <img src="cid:[email protected]"/>',
attachments: [{
filename: 'image.jpg',
content: '/9j/4AA ... Q==',
encoding: 'base64',
cid: '[email protected]'
}]
from: '...',
to: '...',
subject: '...'
}
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport();
transporter.sendMail(mail, function(error, info) {
...
});
I can recieved the mail from Outlook, However the picture cannot show in Outlook. I have 2 question,
- How to show picture in Outlook using nodemailer module (or others)
- How can I print the entire mail include header and body in above code.
Solution 1:[1]
I find the reason of Problem. the module 'nodemailer' I download and installed is the version 0.6.x which have some issue of attachments. ( I haven't check the reason)
After reinstall the version 1.2.x, the attachment works fine.
Solution 2:[2]
Take a look at the message in Outlook and check if the PR_ATTACH_CONTENT_ID
property is really set to "[email protected]"
and the HTML body (PR_HTML
property) references the image using the specified cid
. You can see the data in Outlook using OutlookSpy (I am its author): select the message, click IMessage button on the OutlookSpy toolbar. To see the attachment properties, go to the GetAttachmentTable tab and double click on the attachment.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | bizet |
Solution 2 |