I'm developing a gmail add-on. I have created a feature to create a reply draft when user fill some text inputs and click on a button (There are some API calls to create email body by using these details).
function composeReply(e){ var messageId = e.messageMetadata.messageId; var message = GmailApp.getMessageById(messageId); ...... var msg = { htmlBody: result['email_content'], subject: result['email_subject'] } var draft = message.createDraftReply('', msg); return CardService.newComposeActionResponseBuilder().setGmailDraft(draft).build(); }
In the above function I want to check whether the message have already a reply draft then update that else create a new reply draft Or Is there any way to delete the existing draft before creating a new one