As part of sending a bulk of emails on Gmail, I want to configure the Reply-To address depending on the recipient using Gmail's alias feature and Google Apps Script.
I've come across a problem that the reply-to settings in Gmail drafts created by the Google Apps Script is disabled (nullified) when attempting to send the created draft via the Gmail website, and wondered if anyone can help me with workarounds.
Reproducing
My script looks something like below. My Gmail account, for the sake of providing an example, is [email protected]
:
var subject = 'An Eye-catching Email Subject';
var recipients = [{
email: '[email protected]',
replyTo: '[email protected]',
body: 'email text for [email protected]'
},
{
email: '[email protected]',
replyTo: '[email protected]'
body: 'email text for [email protected]'
}
// which goes on for an order of under 100 recipients
];
recipients.forEach(recipient => GmailApp.createDraft(recipient.email, subject, recipient.body, {
replyTo: recipient.replyTo
}));
When I open one of the created draft messages on the Gmail website, and then send the message by hitting the Send
button, the sent email is set to reply to [email protected]
and not the designated Reply-To aliases, like [email protected]
.
Alternatives
If I use the sendEmail()
method instead of the createDraft()
used above, everything works fine. The designated replyTo
options are reflected in the actual emails sent.
The only reason that I use createDraft()
instead of sendEmail()
is that after the drafts are created, I want to make sure everything is alright before hitting the Send
button, individually. I understand that I should probably just forget using createDraft()
; I just can't figure out what Google intended to do with the replyTo
option of createDraft()
, and if anyone knows some other solution that I could take while sticking to createDraft()
, I am more than grateful.
question from:
https://stackoverflow.com/questions/65878696/how-can-i-keep-the-reply-to-setting-in-gmail-drafts-created-by-gmailapp-createdr 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…