【问题标题】:Nodemailer and ical-generator - to send calendar inviteNodemailer 和 ical-generator - 发送日历邀请
【发布时间】:2021-07-21 09:30:55
【问题描述】:

我想发送日历邀请。我使用Nodemailerical-generator 来生成ical 文件。一切正常,但电子邮件不会自动将邀请添加到日历,而是我可以选择Add to calendar。但我希望电子邮件直接将事件添加到日历中。

这就是电子邮件的样子 -

我的代码如下所示。

此代码转换为 ical 文件,并与Nodemailer icalEvent 一起使用以发送它。

    const content = ical({
    domain: 'google.com',
    method: 'PUBLISH',
    prodId: '//Google Inc//Google Calendar 70.9054//EN',
    timezone: 'Australia/Brisbane',
    scale: 'GREGORIAN',
    events: [
      {
        start: moment(),
        status: 'CONFIRMED',
        end: moment().add(1, 'hour'),
        summary: 'Calendar invite test',
        transparency: 'OPAQUE',
        organizer: {
          name: 'Organiser name',
          email: 'ttt@gmail.com',
          mailto: 'ttt@gmail.com'
        },
        location: 'Zoom',
        attendees: [
          {
            email: 'my-email-address@gmail.com',
            name: 'Shashank Kumar',
            status: 'NEEDS-ACTION',
            rsvp: true,
            type: 'INDIVIDUAL',
            role: 'REQ-PARTICIPANT'
          },
          {
            email: 'mno@gmail.com',
            name: 'Mike Jack',
            status: 'NEEDS-ACTION',
            type: 'INDIVIDUAL',
            role: 'REQ-PARTICIPANT'
          },
          {
            email: 'xyz@gmail.com',
            name: 'Will Paul',
            status: 'NEEDS-ACTION',
            type: 'INDIVIDUAL',
            role: 'REQ-PARTICIPANT'
          }
        ]
      }
    ]
  }).toString();

然后我使用 Nodmailer 发送 icalEvent

message: {
  to: toEmail,
  headers: {
    'x-invite': {
      prepared: true,
      value: id
    }
  },
  icalEvent: {
    filename: 'invite.ics',
    method: 'PUBLISH',
    content: content
  }
},

【问题讨论】:

    标签: node.js express icalendar nodemailer


    【解决方案1】:

    您只需要使用“REQUEST”作为方法而不是“PUBLISH”,这将自动添加到您的日历并显示确认按钮

    【讨论】:

      猜你喜欢
      • 2013-06-09
      • 2019-06-04
      • 2014-05-04
      • 2018-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-14
      • 1970-01-01
      相关资源
      最近更新 更多