首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过Google应用程序脚本向非Google帐户发送日历邀请

通过Google应用程序脚本向非Google帐户发送日历邀请
EN

Stack Overflow用户
提问于 2015-12-06 22:31:58
回答 1查看 2.6K关注 0票数 3

我创建了一个Google表单,它在提交时将信息输入到Google表单中。

我已经创建了一段运行在submit上的Google脚本代码,它创建了一个Calendar事件,并使用在我在表单所有者的Google帐户中创建的一个非主Google日历上创建了该事件。

作为事件对象的一部分,我正在设置一个接收事件邀请的收件人电子邮件地址的attendees属性数组。我还将sendNotifications设置为true。

当通过API创建事件时,我可以看到事件是在我指定的日历中创建的。与会者列表中填充了我指定的收件人电子邮件地址。

拥有Google帐户的收件人将将日历事件作为暂定约会直接添加到他们的日历中。非谷歌收件人(如Hotmail用户、Exchange用户、Office 365等)简单地说,不接收的邀请。

此外,通过日历UI编辑创建的事件会提示我“更新来宾”的更改。确认这将使非Google收件人成功地接收到事件更改的电子邮件通知。此外,通过日历UI直接创建事件并指定非Google与会者也将导致成功传递邀请。

只是通过Calendar API创建事件似乎不起作用。

更复杂的是,如果我访问谷歌事件参考页面并使用表单(使用OAuth连接到API ),那么我可以将数据发布到API并成功地接收来自非Google地址的事件邀请。

我想我可以连接一些帐户,编写一些Google脚本代码,通过OAuth插件授权该服务帐户,并尝试通过某种外部API请求将API调用到Google --但我不确定这是否有效,而且我必须想出如何让OAuth在Google脚本中工作。即便如此,当Google脚本支持在内部使用Calendar API时,似乎有点过分了。

我只是想补充一下:我已经授权脚本通过脚本编辑器的高级谷歌服务区域以及开发者控制台使用Calendar API,正如这篇文章中推荐的那样。

我还发现了这篇文章,它建议修补,这是一个支持发送邀请的事件--结果是一样的,对非谷歌帐户仍然不起作用。

我的代码如下:

代码语言:javascript
复制
  // set variables
  var appointmentWith = "Nick W";
  var location = "The Boardroom";
  var description = "Add some notes to the appointment";
  var calendar = "1v1.....u80@group.calendar.google.com"; // calendar id of calendar
  /*
  joinedStart and endDate are set elsewhere
  */

  // create an event object
  var event = {
    summary: appointmentWith, // the title of the appointment
    location: location, // the location of the appointment
    description: description, // the form description / submitted values
    start: {
      dateTime: joinedStart.toISOString() // start time of the appointment
    },
    end: {
      dateTime: endDate.toISOString() // end time of the appointment
    },
    sendNotifications: true, // email the invite
    attendees: [
      {email: recipient}, // set the recipient email address
      {email: "user@googleaccount.com"},
      {email: "non-google-user@hotmail.com"}
    ]
  };



  Logger.log("creating new calendar event");
  event = Calendar.Events.insert(event, calendar); // creates the event but won't notify non-Google email accounts
  Logger.log(event.id);
  Logger.log("new calendar event created");

  // attempting to patch the event in the hope this will fix the issue
  Logger.log("sending further invites");
  event.attendees.push({email:"user@hotmail.com"});
  event = Calendar.Events.patch(event, calendar, event.id, { sendNotifications:true});

  Logger.log("sent");
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-12-07 14:19:58

这是:

sendNotifications:真,//给邀请发电子邮件

应该将其设置为请求参数,而不是事件体的一部分。

Calendar.Events.insert(事件、日历、{发送通知:true})

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34123667

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档