Writing google script for my Google Spreadsheet.
How can I create a new mail message, populate with some fields (e.g. "To:") and allow the end user to complete the message and click "send"?
I could only find "MailApp.sendEmail" to send an email, but not create a new message without sending...
To clarify: this is not to create a "Draft" message. The script will basically automate the following manual process in Gmail: 1. Click "Compose". 2. Enter "To:"
...and that's it. The script ends and the end user is left to complete the subject, body, and click "Send".
This is the function I wrote and just missing the command to create this email message:
function contactsSendEmail() {
var sh = SpreadsheetApp.getActiveSpreadsheet();
var ss = sh.getActiveSheet();
if (isActiveCellInRange(ss.getRange('Contacts_Table_Anchor').getRow()+1,ss.getRange('Contacts_Table_Anchor').getColumn(),ss.getLastRow(),ss.getLastColumn())) {
var sh = SpreadsheetApp.getActiveSpreadsheet();
var ss = sh.getActiveSheet();
var contactName = ss.getRange(ss.getActiveCell().getRow(),getColumnRowByName('Contacts', 'Name', ss.getRange('Contacts_Table_Anchor').getRow())).getValue();
var contactEmail = ss.getRange(ss.getActiveCell().getRow(),getColumnRowByName('Contacts', 'Email', ss.getRange('Contacts_Table_Anchor').getRow())).getValue();
sh.getRangeByName('Email_Sent_To').setValue(contactEmail);
//Here should come what I'm missing, something like: MailApp.createEmail(contactEmail);
}
}