如何使用`cid`在Node js中嵌入带有覆盖文本CSS的图像

时间:2018-10-08 02:17:32

标签: javascript node.js express npm mean-stack

作为Node的新手,我需要发送带有嵌入在js节点中的图像的邮件。

使用<img>标签和cid发现我们可以发送嵌入的图像。但是我还需要覆盖一些文本。

因此,我发现可以使用网站W3Schools中的CSS来完成此操作,但是邮件不能与CSS一起使用。

使用CSS时如何链接cid

下面是我目前的代码。

`

let mailOptions = {
      from: sender address, 
      to: list of receivers, 
      subject: Subject line,
      cc:requestedByEmail,      
html: '<div style="height: 100%;background-image: url("/images/hero-bg.jpg");background-position: center;background-repeat: no-repeat;background-size: cover;"><div style="background-color: rgb(0,0,0);background-color: rgba(0,0,0, 0.4);color: white;font-weight: bold;border: 3px solid #f1f1f1;position: absolute;top: 50%;left: 50%;transform: translate(-50%, -50%);z-index: 2;width: 80%;padding: 20px;text-align: center;"></div><h2>Blurred Background</h2>  <h1 style="font-size:50px">I am John Doe</h1>  <p>And I\'m a Photographer</p></div></img>',
      attachments: [{
        filename: 'hero-bg.jpg',
        path: __dirname+'/images/hero-bg.jpg',
        cid: 'hb' //same cid value as in the html img src
    }]

`

这是通过电子邮件发送包含CSS的嵌入式图像的方法吗?

有人可以帮我解决这个问题。

0 个答案:

没有答案