email - View message as HTML? -


it seems gmail api returns message , message body mime. possible have return in either plaintext or html? if not, there way me open fetched message , view equivalently how using smtp?

for (message message : messages) {             string messageid = message.getid();             message m = service.users().messages().get(userid, messageid).setformat("full").execute();             system.out.println("message tostring(): " + m.tostring());             system.out.println("message getraw(): "  + m.getraw());             system.out.println("message getpayload().tostring(): " + m.getpayload().tostring());             system.out.println("message getpayload().getbody().getdata(): " + m.getpayload().getbody().getdata());             system.out.println("message getsnippet: " + m.getsnippet());          } 
  1. tostring() returns mime format (i believe?)
  2. getraw() returns null
  3. getpayload() returns part of tostring()?
  4. getpayload().getbody().getdata() returns null
  5. getsnippet returns plaintext snippet of message

gmail guy, 1 useful if wish view properly? assuming tostring(). also, java mime library referring in particular? libraries finding mentioning how determine mime type.

you can make message.get request format=raw , entire email 1 big rfc 2822 string in message.raw field of return type (and parse using java mime libraries)

or (probably better in case)

you can make message.get request format=full , parsed message in message.payload field, tree of parts of email can walk on find text/html, text/plain parts, attachments, other parts, etc. mime formatted emails (anything more 1 part) tree structure, etc.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -