I am working on a Chrome extension for Gmail. I want to obtain the "Message ID" in my extension before the email is sent or just after email is sent. How can I achieve it?
How is message id generated in Gmail?
Is it generated before sending an email or later?
Note: I am not overriding the email functionality. I just need the unique emailID when email is sent in Gmail.
I want to pass this email ID in a request to Gmail API so that I can get the email data as response.
Based on my experience, it is created after sending an email. You can notice that if there is a draft message, there is an ID but once it is sent this ID is converted to its messageID (different value) which you can be use to search in the inbox. You can check this related SO post, that talks about the difference between messageID and draftID. As an example, Mogzdad's code snippet in Apps Script using Gmail API advance Service return the id after sending the email.
Hope this helps.