【问题标题】:Send ICS file via firebase Trigger Email extension通过 firebase 触发电子邮件扩展发送 ICS 文件
【发布时间】:2020-11-06 06:03:38
【问题描述】:

我正在使用 firebase 触发电子邮件扩展程序有什么办法可以在电子邮件上附加 .ics 文件吗?

我正在使用 ics.js 来生成和下载 ics 文件

  let cal = ics()
  cal.addEvent(this.subject,this.desc,this.medium,this.begin,this.end)
  cal.download(this.subject)

我正在使用

发送电子邮件

现在如何将生成的 ics 文件添加到电子邮件中

【问题讨论】:

  • 您能否提供一些您当前的代码以获得更好的上下文?如果我是对的,消息属性有一个“附件”属性,所以我想知道你到底卡在哪里了。
  • @DanielGuzman a 已添加代码

标签: firebase icalendar firebase-extensions


【解决方案1】:

试试这个

firebase.firestore().collection('mail').add({
    to: id,
    message: {
        subject: 'Congratulation!',
        text: 'You Have been hired.',
        html: 'this is <code>HTML</code> code .',
        attachments: [
            {
                path: '/path/to/file.ext'
            },
        ]
    }
})

这里列出了一些如何附加文件的示例

firebase.firestore().collection('mail').add({
    to: id,
    message: {
        subject: 'Congratulation!',
        text: 'You Have been hired.',
        html: 'this is <code>HTML</code> code .',
        attachments: [
            {   // utf-8 string as an attachment
                filename: 'text1.txt',
                content: 'hello world!'
            },
            {   // binary buffer as an attachment
                filename: 'text2.txt',
                content: new Buffer('hello world!','utf-8')
            },
            {   // file on disk as an attachment
                filename: 'text3.txt',
                path: '/path/to/file.txt' // stream this file
            },
            {   // filename and content type is derived from path
                path: '/path/to/file.txt'
            },
            {   // stream as an attachment
                filename: 'text4.txt',
                content: fs.createReadStream('file.txt')
            },
            {   // define custom content type for the attachment
                filename: 'text.bin',
                content: 'hello world!',
                contentType: 'text/plain'
            },
            {   // use URL as an attachment
                filename: 'license.txt',
                path: 'https://raw.github.com/nodemailer/nodemailer/master/LICENSE'
            },
            {   // encoded string as an attachment
                filename: 'text1.txt',
                content: 'aGVsbG8gd29ybGQh',
                encoding: 'base64'
            },
            {   // data uri as an attachment
                path: 'data:text/plain;base64,aGVsbG8gd29ybGQ='
            },
            {
                // use pregenerated MIME node
                raw: 'Content-Type: text/plain\r\n' +
                    'Content-Disposition: attachment;\r\n' +
                    '\r\n' +
                    'Hello world!'
            }
        ]
    }
})

有关更多信息,请查看以下链接:

【讨论】:

  • 如何在不使用ics下载和指定路径的情况下直接附加ics文件?
  • Here 您可以看到手动创建模板作为附件的示例。也许这可以通过在我的答案(使用“raw”的那个)的最后一个例子中使用它来工作?
猜你喜欢
  • 2022-11-20
  • 2010-12-13
  • 2021-05-23
  • 2022-11-20
  • 2021-06-21
  • 2020-02-08
  • 2015-10-17
  • 2013-02-21
  • 1970-01-01
相关资源
最近更新 更多