2

I wanna write a small application that copy Gmail messages from one user folder to another. My approach is next:

  1. Get raw message data to temporary placeholder;
  2. Compose message using raw message data from the previous step;
  3. 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:

  1. use /upload URL (then I need an uploadType string and I should have a content-type of message/rfc822);
  2. 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?

Vasyl
  • 404
  • 1
  • 6
  • 19
  • You don't need to encode the mail into a `raw` string if you are using the `/upload` endpoint. Maybe the [**edit at the bottom of this answer**](https://stackoverflow.com/questions/24908700/mail-attachment-wrong-media-type-gmail-api/24957873#24957873) can give some clues? – Tholle Sep 28 '17 at 17:08
  • I think the problem I described above is clear: I can ether use **/upload** URL and don't set "raw" or don't use **/upload** URL and set "raw" data field in as RFC 2822 formatted and base64url encoded string. – Vasyl Oct 05 '17 at 07:08

0 Answers0