base64 - Gmail API playground: Send method, converted MIME raw header not populating email fields on send -


i'm using google oauth 2.0 playground , attempting send email. autentication working fine. here simple message i'm trying send (email address changed prevent spam):

 to: 'michael to' <fakemichael@gmail.com>  from: 'john from' <johnf@mydomain.com>  subject: 'test message'  htmlbody: '<b>hi!</b><br>test message' 

i convert base64 rfc 822 using vba gets me (i've tried swapping "+" , "-" per other stackoverflow posts no avail):

dg86icdnawnoywvsifrvjya8rmfrzu1py2hhzwxaz21hawwuy29tpg1mcm9toiansm9obibgcm9tjya8sm9obkzabxlkb21haw4uy29tpg1zdwjqzwn0oianvgvzdcbnzxnzywdljw1odg1sqm9ketogjzxipkhjitwvyj48yni-vgvzdcbnzxnzywdljw==

in playground method post , i've added 2 headers:

raw: , base64 string above (no quotes or anything) content-type: message/rfc822 <i added because kept getting different error. putting prevetned error> 

request uri (removed https cause won't let me post more 2 links)://www.googleapis.com/upload/gmail/v1/users/me/messages/send

i click "send request" , ok response:

here request:

post /upload/gmail/v1/users/me/messages/send http/1.1 host: www.googleapis.com raw: <string above> content-length: 0 content-type: message/rfc822 authorization: bearer <my token> 

response:

http/1.1 200 ok alternate-protocol: 443:quic,p=1 content-length: 91 expires: fri, 01 jan 1990 00:00:00 gmt vary: origin, x-origin server: uploadserver ("built on jun 6 2015 11:14:45 (1433614485)") etag: "yanof_dhyoakpariszqhtvrsqto/nwevnuuzauu_lb19l-uhrwaausm" pragma: no-cache cache-control: no-cache, no-store, max-age=0, must-revalidate date: wed, 10 jun 2015 15:59:36 gmt content-type: application/json; charset=utf-8 {   "labelids": [     "sent"   ],    "id": "14dde32bc92c9xyz",    "threadid": "14dde32bc92c9xyz" } 

however, when go gmail sent mail folder, message there nothing in to, subject, or body field: see screenshot

i have imagine simple, i'm new google gmail api, mime, , dealing raw base64 stuff, i'm not having luck.

thanks in advance assistance.

--- edit per tholle's response ---

that helps! removed raw base64 string header , put:

from: 'john from' <johnf@mydomain.com> subject: test message to: 'michael to' <fakemichael@gmail.com> test message 

into "enter request body" , sends, great!

three follow questions:

  1. are there security risks or limitations (max length? see there might 2mb limitation lot of text.) sending way (in body) opposed raw base64 string in header?
  2. (i'll dig more on this) how make message body html? content type of "content-type: message/rfc822" prevent me being able send html? sending html requirement application , can't have 2 content types, there html parameter can use or out of luck?
  3. (i'll homework on well) how include attachment, pdf file, email?

thanks again!

i think violating few minor details of rfc 822 standard:

it recommended that, if present, headers sent in order "return- path", "received", "date", "from", "subject", "sender", "to", "cc", etc.

i can't find life of me, think headers has have first character capitalized. try this:

from: john <johnf@mydomain.com> subject: test subject to: michael <fakemichael@gmail.com>  test message 

you don't want send base64-encoded mail if choose message/rfc822 content-type. supply example mail above is.

post /upload/gmail/v1/users/me/messages/send http/1.1 host: www.googleapis.com content-length: 108 content-type: message/rfc822 authorization: bearer {your_access_token}  from: john <johnf@mydomain.com> subject: test subject to: michael <fakemichael@gmail.com>  test message 

if want html, modify message this:

from: john <johnf@mydomain.com> subject: test subject to: michael <fakemichael@gmail.com> content-type: text/html; charset=utf-8 content-transfer-encoding: quoted-printable  <b>test message</b> 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -