使电子邮件客户端将电子邮件解释为事件 [英] Make an email be interpreted as an event by mail clients

查看:217
本文介绍了使电子邮件客户端将电子邮件解释为事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试发送一封电子邮件,邮件客户端会将其解释为事件.这与我的另一个问题有关.

I'm trying to send an email that will be interpreted as an event by mail clients. This is related to another question of mine.

此代码从Google日历中提取事件,然后从中构建一个VEVENT,将其转换为.ics blob,然后将其附加到电子邮件中.

This code pulls an event from a google calendar, and then builds a VEVENT out of it, converts that to a .ics blob and attatches it to an email.

但是,当邮件客户端收到此邮件时,会将其视为带有附件的电子邮件,但我真正想要的是将其视为事件更新.

However when this is received by the mail client it treats it as an email with an attachment, but what I really want is for it to be treated as an event update.

当我剖析事件电子邮件时,它包含两个.ics文件(相同的内容,不同的文件名)和一个.html文件,该文件与.ics中的DESCRIPTION:相同.

When I dissect an event email it contains two .ics files (identical contents, different file names) and a .html file that contains the same as the DESCRIPTION: in the .ics.

我想知道的是我要告诉邮件客户端这是一个事件,以及是否与重复的ics文件和html文件有关.

What I'd like to know is what I need to do to tell the mail client that this is an event, and if that relates to the duplicate ics files and the html file.

function fixInvitations(){
  //get the callendar named "Appraisals"
  var cApp = CalendarApp.getCalendarsByName("Bris Appraisals")[0];
  var events = cApp.getEvents(new Date(), new Date("Dec 30 2014"));

  var e = events[5];
  var icsFile = makeICS(e);
  var mail_options={
                      body:     "Your updated appraisal etc. etc.",
                      htmlBody: "<p>Your updated appraisal etc. etc.</p>",
                      name: "Appraisals Scheduling Robot",
                      noReply: true,
                      /*replyTo: ,*/
                      subject: "Your updated appraisal",
                      to: "myworkEmail@bvn.com.au, mygoogleEmail@notionparallax.co.uk",
                      attachments:[icsFile]
                    };
  Logger.log(mail_options);
  MailApp.sendEmail(mail_options);
}

function ldapDate(d){
  //TODO: make this take Bris or syd to decide on a timezone
  var formattedDate = Utilities.formatDate(d, "GMT+11:00", "yyyyMMddHHmmss");
  Logger.log([d, formattedDate])
  return formattedDate+"Z";
}

function makeICS(event){
  var e = event;
  var attendees = [];
  var guests = e.getGuestList();

  for(g in guests){
    var guest = guests[g];
    var atendee =[
    "ATTENDEE;",  "CUTYPE=INDIVIDUAL;",  "ROLE=REQ-PARTICIPANT;",
    "PARTSTAT=NEEDS-ACTION;",  "RSVP=TRUE;",  "CN="+guest.getName()+";",
    "X-NUM-GUESTS=0:mailto:"+guest.getEmail()
      ].join("");
    attendees.push(atendee);
  }

  var vcal = ["BEGIN:VCALENDAR",
              "PRODID:-//Google Inc//Google Calendar 70.9054//EN",
              "VERSION:2.0",
              "CALSCALE:GREGORIAN",
              "METHOD:REQUEST",
              "BEGIN:VEVENT",
              "DTSTART:" + ldapDate(e.getStartTime()),
              "DTEND:"+ ldapDate(e.getEndTime()),
              "DTSTAMP:" + ldapDate(new Date(Date.now())),
              "ORGANIZER;CN=" + CalendarApp.getCalendarById(e.getOriginalCalendarId()).getName() + ":mailto:" + e.getOriginalCalendarId(),
              "UID:" + e.getId(),
              attendees.join("\n"),
              "CREATED:" + ldapDate(e.getDateCreated()),
              "DESCRIPTION:" + e.getDescription(),
              "LAST-MODIFIED:" + ldapDate(new Date(Date.now())), // although if I wasn't changing things as I issue this it'd be e.getLastUpdated()
              "LOCATION:" + e.getLocation(),
              "SEQUENCE:"+Date.now(),//this is a horrible hack, but it ensures that this change will overrule all other changes.
              "STATUS:CONFIRMED",
              "SUMMARY:" + e.getTitle(),
              "TRANSP:OPAQUE",
              "END:VEVENT",
              "END:VCALENDAR"
  ].join("\n");

  var icsFile = Utilities.newBlob(vcal, 'text/calendar', 'invite.ics');
  Logger.log(vcal);
  Logger.log(icsFile);
  return icsFile;
}

推荐答案

尝试在另一个Notes客户端的Notes中向用户发送会议请求,并检查创建的字段.这就是我过去的做法.

Try sending a meeting request to a user in notes from another notes client and checking out the fields created. This is how I did this in the past.

我有一些代码可以创建.ics提要,因此用户可以根据需要使用添加日历"功能将它们添加到他们的Notes日历中. 例如: http://camberleycricket.com/cc.nsf/calendar.ics 与其他日历系统一样,这是使用提要的最新方法.

I have some code that will create a .ics feed so the user can add them into their Notes calendar using the "add a calendar" feature if you need it. eg: http://camberleycricket.com/cc.nsf/calendar.ics Neatest way as then other calendar systems can use the feed.

这篇关于使电子邮件客户端将电子邮件解释为事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆