Node.js 发送带有内联图像的邮件时图像中的Cid不工作

Node.js 发送带有内联图像的邮件时图像中的Cid不工作,node.js,base64,nodemailer,inline-images,Node.js,Base64,Nodemailer,Inline Images,我有一个带有内联图像集的邮件正文,如下所示: <img src="cid:<<content-id>>"> 我正在使用nodemailer发送邮件。我也有一个相对的图像URL。但Outlook中未显示该图像。似乎cid不适用于Outlook的最新版本 其他选择 是否可以在nodejs中获取映像的base64。我已经看到了canvas和xmlhttprequest的示例,但如果不使用我不想使用的外部模块,就无法在node中完成 如果您的html属性是: <

我有一个带有内联图像集的邮件正文,如下所示:

<img src="cid:<<content-id>>">
我正在使用nodemailer发送邮件。我也有一个相对的图像URL。但Outlook中未显示该图像。似乎cid不适用于Outlook的最新版本

其他选择

是否可以在nodejs中获取映像的base64。我已经看到了canvas和xmlhttprequest的示例,但如果不使用我不想使用的外部模块,就无法在node中完成

如果您的html属性是:

<p><img src="cid:c001" /></p>
对于其他嵌入图像,只需将它们添加到附件数组中

上述操作将生成一封邮件,如下所示:

[ { path: "data:image/gif;base64,...image data here....",
     cid: "c001"
} ]
Content-Type: multipart/alternative; boundary="s1"

--s1
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

    ...the (plain)`text` part of your message
--s1
Content-Type: multipart/related; type="text/html"; boundary="s2"

--s2
Content-Type: text/html

<p><img src="cid:c001" /></p>
--s2

Content-Type: image/gif; name=attachment-1.gif
Content-ID: <c001>
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=attachment-1.gif

...image data here....
--s2
--s1