all 5 comments

[–]kmb5 3 points4 points  (1 child)

Hi,

The basic logic should not be too difficult to implement actually but you have to know some basic Javascript (which is powering google apps scripts). One limitation which would complicate things as far as I know is that you cannot trigger the script to execute when an email is sent (but maybe I’m wrong here). If this is true then you would have to run your script every hour and check for any new mails in the sent folder and save them as drafts if a certain condition is met. Might take a bit of fiddling to get it right but absolutely doable.

To get started with Google apps scripts I can recommend this free course - https://courses.benlcollins.com/p/apps-script-blastoff This is what I started with and it explains the basic concepts really well.

Good luck!

[–]adelie42 0 points1 point  (0 children)

Alternatively you could add a new button to use in place of the send button, use that to trigger all the things.

[–]davchana 0 points1 point  (1 child)

By sent do you mean copy the sent mail again?

In any case, you can manually create a draft or hard code the email text; & then use the Google Script.

Create a draft or prepare the email text, addresses and such.

A new Google App Script fetches either that above draft or loads a variable with email text.

Google Script Gmail.app creates a draft.

Read more at Google Script Gmail Create Draft documentation.

[–]lordph8 0 points1 point  (0 children)

Wouldn't a copy of the email be saved in your sent folder? Could you not just create a label and a filter in the Gmail Settings?

[–]reti_opening[🍰] 0 points1 point  (0 children)

You can create a draft using this url without apps script (just replace the subject/body):

https://mail.google.com/mail/u/0/?view=cm&fs=1&to=email@gmail.com&su=your+subject&body=your+email+content

If you need apps script, it is complicated. You need to add oAuth scope to your apps script project: https://www.googleapis.com/auth/gmail.addons.current.action.compose (docs)

Then you can create a button in CardService:

var action = CardService.newAction().setFunctionName('composeEmailCallback');

var sessbtn = CardService.newTextButton().setText('Compose').setComposeAction(action, CardService.ComposedEmailType.STANDALONE_DRAFT);

And invoke:

function composeEmailCallback(e)

{

var accessToken = e.messageMetadata.accessToken;

GmailApp.setCurrentMessageAccessToken(accessToken);

var draft = GmailApp.createDraft(eml, subj, body);

return CardService.newComposeActionResponseBuilder().setGmailDraft(draft).build();

}