I wanna write a small application that copy Gmail messages from one user folder to another. My approach is next:
- Get raw message data to temporary placeholder;
- Compose message using raw message data from the previous step;
- Add message to required folder.
I can get raw message data as RFC 2822 formatted and base64url encoded string using this get request.
Also I can insert message to user mailbox with insert request. As documentation states, I can use one of the next two approaches:
- use /upload URL (then I need an uploadType string and I should have a content-type of message/rfc822);
not using /upload URL and simply set message metadata in the request body - something like the next JSON:
{ "labelIds": [ "INBOX", "CATEGORY_PROMOTIONS" ], "raw": "UmVjZWl2ZWQ6IGZyb20gMjkyODI0MTMyMDgyDQoJ..." }
Unfortunately, when I don't use /upload URL (approach (2)) I can't insert message with attachment bigger than 5MB. But if I use /upload URL (approach (1)) I get response with error
"Media type 'message/rfc2822' is not supported. Valid media types: [message/rfc822]".
How can I support insertion of messages to Gmail without restriction on messages attachment size?