Copy Email Messages in Gmail with Apps Script

This example shows how to create email copies in Gmail with Google Apps Script and the Gmail API. The requires requires authorization with the scope https://mail.google.com/ for reading Gmail drafts and composing new ones.

The uploadType is set to media and that will create the Gmail draft in a single HTTP request. However, if you are create a draft that includes big attachment, you may have to set the upload type as resumable to create the draft in at least two requests.