通过nodemailer发送iCal-Entry:与会者响应时处理和更新Outlook-Calendar-Entry

时间:2019-06-28 11:38:06

标签: javascript node.js outlook icalendar

我在处理来自已发送的iCal邀请的回复时遇到问题。 我有一个nodeJS-Backend,它使用nodemailerical-generator将会议邀请发送到与会者列表。 (下面的代码)

我通常要做的是:

  1. 与参加者一起创建iCal
  2. 设置组织者
  3. 使用REQUEST方法将其发送给所有与会者和组织者(bcc)

现在,我想为与会者提供rsvp-option,因此我将此值设置为true。 现在,当与会者以“已接受” |“已接受” |“已取消”进行答复时,组织者电子邮件帐户收到了答复,但相应的iCal条目根本没有更新。

Outlook接缝无法将响应链接到iCal-Entry。绝对有道理,因为iCal不是由组织者帐户创建的,而是由服务器本身创建的。

所以我的问题是: 是否有可能从服务器向与会者和组织者发送iCal条目,然后通过更新组织者日历中的Calendar-Entry来接收与会者的响应?

我尝试了几件事,尝试使用iCal-Entry的UID,切换方法(请求,发布等),但没有任何帮助。

这里有任何Outlook-Cracks谁可以提供意见?也许使用Sharepoint-Calendar或类似的方法?

真的坚持这一点,并感谢任何提示。

代码食谱

创建iCal条目的代码:

createIcal(calTitle, startDate, endDate, esTitle, esDescription, method, attendees) {
        let cal = icalGenerator({
            domain: 'test.de',
            name: calTitle,
            timezone: 'Europe/Berlin',
            method: method
        });
        startDate = new Date(startDate);
        endDate = new Date(endDate);

        cal.prodId({
            company: 'Test AG',
            product: 'Test product',
            language: 'DE'
        });

        let formattedAttendees = [];
        if (attendees) {
            for (let attendee of attendees) {
                formattedAttendees.push({
                    email: attendee.email,
                    rsvp: true,
                    status: 'accepted',
                    type: 'individual',
                    role: (attendee.email === 'organizer@email.de' ? 'chair':'req-participant')
                });
            }
        }


        let ev = cal.createEvent({
            start: startDate,
            end: endDate,
            summary: esTitle,
            description: esDescription,
            location: 'somewhere',
            url: 'https://test.de',
            organizer: {
                name: 'organizer@email.de',
                email: 'organizer@email.de',
                mailto: 'organizer@email.de'
            },
            attendees: formattedAttendees
        });
        return cal.toString();
    }

使用ics实际发送电子邮件的代码:

async sendmail(receivers, subject, html, iCal, iCalMethod) {
        html = '<html><body>' + html;
        html += '</body></html>';

        let plainText = EmailTemplate.getPlainTextFromHTML(html);

        let smtpOptions = {
            name: 'test.de',
            host: 'mx.test.de',
            port: 587,
            pool: true,
            auth: {
                user: 'test',
                pass: 'test'
            },
            secure: false,
            tls: {
                rejectUnauthorized: false
            }
        };

        let transporter = nodemailer.createTransport(smtpOptions);

        let mailOptions = {
            from: 'admin@test.com',
            bcc: receivers,
            subject: subject,
            html: html,
            text: plainText
        };
        if (iCal) {
            /*mailOptions.alternatives = [{
                contentType: 'text/calendar; charset="utf-8"; method=' + iCalMethod,
                content: iCal
            }]*/
            mailOptions.icalEvent = {
                filename: 'test.ics',
                method: iCalMethod,
                content: iCal
            }
        }

        // verify connection configuration
        transporter.verify(function (error, success) {
            if (error) {
                console.log(error);
            } else {
                console.log("Server is ready to take our messages");
            }
        });

        if (receivers.length > 0) {
            transporter.sendMail(mailOptions, function (error, info) {
                if (error) {
                    console.log(error);
                } else {
                    console.log('Email sent: ' + info.response);
                }
            });
        }
    }

0 个答案:

没有答案