1

I am using firebase trigger email extension Is there any way i can attach .ics file on the email ?

i am using ics.js for generating and diect downloading ics file

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

i am sending the email using

now how can i add the generated ics file on email

mayank3503
  • 315
  • 4
  • 17
  • Can you please provide some of your current code to have a better context? If I'm right, there's a property for "attachment" for the message property, so I'd like to know where exactly are you stucked. – Daniel Guzman Jul 16 '20 at 14:35
  • @DanielGuzman a have added the code – mayank3503 Jul 16 '20 at 15:02

1 Answers1

2

Try this

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'
            },
        ]
    }
})

Here's a list of some examples how you'd attach your files

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!'
            }
        ]
    }
})

For more further information, take a look at these links:

Daniel Guzman
  • 588
  • 2
  • 8
  • how can a attach ics file directly without using ics downoad and specifying path? – mayank3503 Jul 16 '20 at 15:27
  • [Here](https://help.appsheet.com/en/articles/3568441-adding-a-calendar-ics-attachment-to-an-email) you can see an example of Manually Creating the Template as an attachment. Maybe this can work by using it on the last example of attachemen on my answer (the one that uses "raw")? – Daniel Guzman Jul 16 '20 at 15:42