Weird Behavior - GmailApp.getDraft(did).getMessage().getPlainBody();

95 views
Skip to first unread message

Preet Mehta

unread,
Jun 2, 2022, 10:45:03 AM6/2/22
to Google Apps Script Community
So, 

I have created a draft using...
var draftID = GmailApp.createDraft(
    email, 
    subject, 
    emailString,
  { name: "some name", htmlBody: htmlMessage} );

If I use 
.getPlainBody() on a draft got using the getDraft("draft ID")
and then its plain body, using .getPlainBody()

The output varies between following 2 types...
1. Some times it gives emailString, the 3 parameter from the createDraft API, which I believe is the message for non-html based emails.
2. Some times it gives the plainBody extracted from the htmlMessage!

Now, actually I am not able to understand on what basis the output changes?
Can anyone please help?
Reply all
Reply to author
Forward
0 new messages