我如何收到客人的电子邮件

时间:2019-07-03 19:31:12

标签: google-apps-script google-sheets gsuite

我正在尝试让活动邀请对象的电子邮件地址进入我拥有的Google工作表中

我正在尝试使用该功能 事件[i] .getGuestByEmail(电子邮件) 但是我不知道如何输入字符串(它表示电子邮件未定义。

var header = [["Calendar Address", "Event Title", "Event 
Description", "Event Location", "Event Start", "Event End", 
"Calculated Duration", "Visibility", "Date Created", "Last Updated", 
"MyStatus", "Created By", "All Day Event", "Recurring Event", 
"Guests"]]
var range = sheet.getRange(1,1,1,15);
range.setValues(header);


// Loop through all calendar events found and write them out 
 starting on calulated ROW 2 (i+2)
for (var i=0;i<events.length;i++) {
  var row=i+2;
  var myformula_placeholder = '';
  // NOTE: I've had problems with the getVisibility for some older     events not having a value, so I've had do add in some NULL text to make     sure it does not error
  var details=[[mycal,events[i].getTitle(), even    ts[i].getDescription(), events[i].getLocation(), events[i].getStartTime(), events[i].getEndTime(), myformula_placeholder, ('' + events[i].getVisibility()), events[i].getDateCreated(), events[i].getLastUpdated(), events[i].getMyStatus(), events[i].getCreators(), events[i].isAllDayEvent(), events[i].isRecurringEvent(), events[i].getGuestByEmail(email))]];

我需要它用访客的电子邮件地址填充电子表格

1 个答案:

答案 0 :(得分:0)

要获取邀请对象的电子邮件,您需要使用@IMTheNachoMan建议的events[i].getGuestList(),但是要以某种希望的方式在代码中使用它,则有些许不同。 getGuestList()将带给您一系列参加该活动的嘉宾,您可以连接以下代码来跟踪他们的电子邮件:

var guests = events[i].getGuestList();
var guestEmails;

for (var j = 0; j < guests.length; j++){
    guestEmails.push(guests[j].getEmail();
    Logger.log(guestEmails[j]);
}

这将为您提供一系列电子邮件,您以后可以访问并将其添加到电子表格中。 getGuestList()方法here的文档。