Reputation: 7052
I would like to mail the current google sheet URL like https://docs.google.com/spreadsheets/d/19sig7bVj6m247Gxap92Bc7-eb5TAMn4NQng9k_Zsqrk/edit#gid=0
. My code in Code.gs
is like below.
var TO_ADDRESS = "[email protected]";
var sendEmailTo = (typeof TO_ADDRESS !== "undefined") ? TO_ADDRESS : mailData.formGoogleSendEmail;
if (sendEmailTo) {
MailApp.sendEmail({
to: String(sendEmailTo),
subject: "Contact form submitted",
htmlBody: SpreadsheetApp.getActiveSpreadsheet() //this is not working
});
}
How can I fetch current google sheet URL ?
Upvotes: 0
Views: 109
Reputation: 104
var url = SpreadsheetApp.getActiveSpreadsheet().getUrl()
if (sendEmailTo) {
MailApp.sendEmail({
to: String(sendEmailTo),
subject: "Contact form submitted",
htmlBody: url
});
}
Upvotes: 1