Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Gmail/Sheets Mail Merge exiting with "Oops - can't find Gmail draft" error if more than one draft in folder #159

Open
gouvtarkin opened this issue Nov 3, 2020 · 0 comments

Comments

@gouvtarkin
Copy link

Hi,

I stumbled across https://developers.google.com/gsuite/solutions/mail-merge and would like to share: It works! Kudos to you for putting the together and share it with everyone here.

However, to make it work, I had to delete all other 135 drafts in my draft folder, so that there is only the one remaining which is supposed to be used.

As far as I can tell, the issues is caused by following two lines in script:

// get drafts
const drafts = GmailApp.getDrafts();
// filter the drafts that match subject line
const draft = drafts.filter(subjectFilter_(subject_line))[0];

Having run the script in debug mode, drafts showed up as an array of 136, while draft remained unassigned.

After deleting the other 135 drafts from the draft folder, the script ran through without issues (and without modifications).

Arne

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant