2
我試圖發送一封電子郵件,該郵件將被郵件客戶端解釋爲事件。這與another question of mine有關。通過郵件客戶端將電子郵件解釋爲事件
此代碼從Google日曆中提取事件,然後從中創建VEVENT,將其轉換爲.ics
blob並將其附加到電子郵件中。
然而,當這是由郵件客戶端也將其視爲帶有附件的電子郵件,但我真的希望收到的是讓它作爲一個事件更新處理。
當我仔細分析事件的電子郵件它包含兩個.ics
文件(相同的內容,不同的文件名)和.html
文件,其中包含相同的.ics
的DESCRIPTION:
。
我想知道什麼是我需要做的,告訴郵件客戶端,這是一個事件,如果涉及重複ICS文件和html文件。
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: "[email protected], [email protected]",
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;
}
請向我們展示由此產生的電子郵件。無法幫助您解決實際的MIME消息。 – arnaudq
那麼一個低科技的社會工程選項如何,你的事件的標題是「重新安排的評估日期:新的約會:」+ oldDate +「移到:」+ newDate?如果您可以在「是」,「否」或可能的選項上方添加一行文本,請添加「如果新日期適合您,請點擊下面的選項以指示確認,拒絕或許可。」或者是這個效果。是否有可能爲按鈕上出現的內容編程文本覆蓋,或者使ics中的「可能」按鈕消失/不可見? – thoughtcrime