使用Google应用脚本编辑Google日历活动时更新与会者 [英] Update attendees when editing a Google calendar event with Google apps script

查看:161
本文介绍了使用Google应用脚本编辑Google日历活动时更新与会者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况



我有一个包含很多活动的日历(员工评估)。

我已经做了一些修改(改变事件的长度等),但邀请函发送给有莲花笔记日历的人(穷人)。

这意味着除非我触发了所谓的发送通知?。在使用鼠标点击的版本中,他们无法知道该事件已被更新。



()。这包含一个VCALENDAR和一个VEVENT。来自 VEVENT上的Wikipedia页面


要发送事件的UPDATE,UID应该与原始UID匹配。要设置的其他组件属性为:

SEQUENCE:<更新数量>



即第一次更新:

SEQUENCE:1 因此,如果有一种方法可以手动建立一个包含 .ics 附件的电子邮件它会解决这个问题,但这感觉像是大规模的过度杀伤。 这里提到,但不是已解决。

解决方案

我一直在为这个问题苦苦挣扎,并从ekoleda+devrel@google.com获得一些帮助:将电子邮件邀请发送给通过addGuest添加的用户的日历 http ://code.google.com/p/google-apps-script-issues/issues/detail?id = 574



一些指向希望可以节省一些时间:


请注意,CalendarApp和Advanced Calendar服务使用不同的
事件ID格式:



  • CalendarApp在结尾处使用@ google.com返回事件ID。 b3gv ... a5jrs@google.com

  • 高级日历服务/日历API预计没有@ google.com ex的事件ID。 b3gv ... a5jrs


以下是一些工作代码:

 函数sendInvite(calendarId,eventId,email){
var event = Calendar.Events.get(calendarId,eventId) ;
if(event.attendees){
event.attendees.push({
email:email
});
} else {
event.attendees = new Array({email:email});
}
event = Calendar.Events.patch(event,calendarId,eventId,{
sendNotifications:true
});
}

随后的最后一张笔记 - 您将不会收到电子邮件通知如果您是活动负责人,并且您尝试添加自己的电子邮件地址。这在日历世界中很有意义,因为您不会进入自己的日历活动,将自己添加为与会者,并希望提示您是否要通知自己。然而,这可能是人们尝试和测试东西的一种常见方式(我没有域测试帐户,也不能始终可靠地使用我的个人Gmail帐户进行测试)。因此,如果您使用自己的帐户进行测试并认为事情无效,请记住这一点。一旦您尝试使用非活动所有者帐户,邀请将通过电子邮件发送。


Situation

I have a calendar with a lot of events on it (staff appraisals).

I've made a load of modifications (changing the length of the event etc.) but the invitations are going to people who have a lotus notes calendar (poor people).

This means that unless I trigger what would be called "Send notification?" in the click-with-your-mouse version of things, they have no way of knowing that the event has been updated.

(Similar Q)

In this example, the event I'm trying to trigger is the same one as is triggered when the Send Update? modal is accepted with send.

Code

Here's some example code that gets all the events on the Appraisals calendar and changes their location to 'the moon'.

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

  for (eIndex in events){
    var event = events[eIndex];
    event.setLocation("the moon");
  }
}

Question

How do I trigger an update to all parties invited to an event so that the changes are reflected in their calendars?

Currently these events are now on the moon, but the update hasn't told people who are on non-Google calendars about the change.

Helpful, but not that helpful fact

The update email that manually triggering sends contains a .ics file (Gist of the contents). This contains a VCALENDAR and a VEVENT. From the Wikipedia page on VEVENTs

For sending an UPDATE for an event the UID should match the original UID. the other component property to be set is:

SEQUENCE:<Num of Update>

I.e., for the first update:

SEQUENCE:1

So if there was a way to manually build an email with a .ics attachment it would solve the problem, but that feels like massive overkill. This is mentioned here but not resolved.

解决方案

I was struggling with this one a bit and got some help from ekoleda+devrel@google.com: Ability for Calendar to send email invitation to users added via addGuest http://code.google.com/p/google-apps-script-issues/issues/detail?id=574

A couple of pointers to hopefully save people some time:

Note that CalendarApp and the Advanced Calendar service use different event ID formats:

  • CalendarApp returns event IDs with "@google.com" at the end ex. b3gv...a5jrs@google.com
  • The Advanced Calendar service/Calendar API expects an event ID that does not have @google.com ex. b3gv...a5jrs

Here's some working code:

function sendInvite(calendarId, eventId, email) {
  var event = Calendar.Events.get(calendarId, eventId);
  if(event.attendees) {
    event.attendees.push({
      email: email
    });
  } else {
    event.attendees = new Array({email: email});
  }
  event = Calendar.Events.patch(event, calendarId, eventId, {
    sendNotifications: true
  });
}

One final note for those following along - you won't receive an email notification if you're the event owner and you're trying to add your own email address. This makes sense in the calendar world since you wouldn't go into your own calendar event, add yourself as an attendee, and expect to be prompted as to whether or not you want to inform yourself. However, it's probably a common way for people to try and test things (I don't have a domain test account and I can't always reliably test things with my personal gmail account). So if you're testing with your own account and thinking that things aren't working please keep this in mind. Once you try things with a non-event owner account the invite will be sent via email.

这篇关于使用Google应用脚本编辑Google日历活动时更新与会者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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