Gmail Templates and Apps Script

1,006 views
Skip to first unread message

Clark Lind

unread,
Jul 28, 2021, 12:42:04 PM7/28/21
to Google Apps Script Community
Hi All,
Has anyone found a way to tap into Gmail's templates yet? I know the basic way to do a mail merge is make a copy of a draft and go from there. I think it would make better sense to use the templates so you don't have to clutter up your draft folder. 

The Draft method seems to be a hack and workaround as that has been the only way to save "templates". But now there actually are templates.

Thoughts? Ideas?

Thanks, Clark

Alan Wells

unread,
Jul 28, 2021, 1:32:59 PM7/28/21
to Google Apps Script Community
I took a quick look at the documentation for GmailApp and the Gmail API, and I don't see any methods in either that can create or get an email template.

Martin Hawksey

unread,
Jul 28, 2021, 1:55:26 PM7/28/21
to google-apps-sc...@googlegroups.com
Hi Clark - nice idea but my understanding is template messages (previously called canned responses) get stored in your drafts folder https://stackoverflow.com/a/56594385/1027723 (a brief test confirms this for my @gmail.com account)

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/f0cf28b6-f1a3-4f9b-9c4c-334b81ddecbfn%40googlegroups.com.

Clark Lind

unread,
Jul 28, 2021, 5:42:22 PM7/28/21
to google-apps-sc...@googlegroups.com
Thanks Martin,
That helps a lot. The templates are actually there as draft messages, they just don't show up in your Drafts folder. So basically, we are right back where we started, just more complicated! lol ;)

You received this message because you are subscribed to a topic in the Google Groups "Google Apps Script Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-script-community/AK_tEiVYcXM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/CAEZbQn8gHzprq2xxY7zmeYCF6VjxQ5jZnVv2yCoc0G%3DmUgvjFA%40mail.gmail.com.

cbmserv...@gmail.com

unread,
Jul 28, 2021, 7:13:02 PM7/28/21
to google-apps-sc...@googlegroups.com

Do you have any special requirements for these canned responses?

 

Like who can modify them or how often they can change?

 

Did you consider just making a function to code the template together rather than starting with a template?

Clark Lind

unread,
Jul 30, 2021, 10:18:08 AM7/30/21
to Google Apps Script Community
Some background: The request came to me from a coworker who wanted to set up a mail merge using a sheet containing 200+ contacts and specific content unique to only that contact. (imagine 200+ scientists contributing to a scientific publication or textbook, and you are sending them all the same email but based on their unique input to the project).

One idea for using the templates was any special formatting like HTML, inline images, css, etc.  But since I now know that the canned messages are all saved as Drafts, I can grab them all, get their subjects, and put all of them in a dropdown inside the google sheet. It will be user-centered, so only those templates the user has saved will show up in the dropdown selection. 

As for your last point, the users will need to be able to create their own templates and save them, so can't really hard code anything ahead of time.

Reply all
Reply to author
Forward
0 new messages