[英]Add a Quick Add Event to a Google Calendar from inside a Google Spreadsheet
I've looked all over but I can't figure out how to add a quick calendar event to google calendar from inside a google spreadsheet. 我已经看了很多遍,但是我不知道如何从Google电子表格中向Google日历添加快速日历事件。 Google provides code (Javascript) to send an email from inside a google spreadsheet, but in addition to sending an email I want to be able to send a quick cal event.
Google提供了用于从Google电子表格内部发送电子邮件的代码(Javascript),但是除了发送电子邮件之外,我还希望能够发送快速事件。 Here is the Javascript I'm starting out with and I copied and pasted the last line which was a code I found about calendar quick add.
这是我刚开始使用的Javascript,我复制并粘贴了最后一行,这是我发现的有关日历快速添加的代码。 This is my first time coding or using javascript.
这是我第一次编码或使用javascript。
function sendEmails() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 2; // First row of data to process
var numRows = 2; // Number of rows to process
// Fetch the range of cells A2:B3
var dataRange = sheet.getRange(startRow, 1, numRows, 2)
// Fetch values for each row in the Range.
var data = dataRange.getValues();
for (i in data) {
var row = data[i];
var emailAddress = row[0]; // First column
var message = row[1]; // Second column
var subject = "CRM Update";
MailApp.sendEmail(emailAddress, subject, message);
CalendarApp.getDefaultCalendar().createEventFromDescription();
}
}
I also found this code, but it might be a diff language? 我也找到了这段代码,但这可能是差异语言吗?
function createQuickAddEvent ($client, $quickAddText) {
$gdataCal = new Zend_Gdata_Calendar($client);
$event = $gdataCal->newEventEntry();
$event->content = $gdataCal->newContent($quickAddText);
$event->quickAdd = $gdataCal->newQuickAdd('true');
$newEvent = $gdataCal->insertEvent($event);
}
Any advice would be useful, or directing me to a page that might have this code I'm looking for. 任何建议都是有用的,或者将我定向到可能包含我要查找的代码的页面。 Thanks for your time.
谢谢你的时间。 Michael
麦可
You should use GAS (Google Apps Script - https://developers.google.com/apps-script/ ), which you can embed inside your spreadsheet. 您应该使用GAS(Google Apps脚本-https: //developers.google.com/apps-script/ ),您可以将其嵌入电子表格中。 It is similar to JavaScript with additions.
它与JavaScript类似,但有所不同。 The first example above is GAS (the second is php which is one of the languages that have client libraries to Google API - https://developers.google.com/discovery/libraries )
上面的第一个示例是GAS(第二个示例是php,这是具有Google API客户端库的一种语言-https: //developers.google.com/discovery/libraries )
The script can be attached to a menu item that you can add to the spreadsheet or as a trigger to changes in the spreadsheet and even building a dedicated UI for event adding. 脚本可以附加到菜单项,您可以将其添加到电子表格中,也可以触发电子表格中的更改,甚至可以构建用于添加事件的专用UI。
Check out the documentation for adding calendar event with GAS at: https://developers.google.com/apps-script/class_calendar#createEvent 在https://developers.google.com/apps-script/class_calendar#createEvent中查看有关使用GAS添加日历事件的文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.