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()); }
- tostring() returns mime format (i believe?)
- getraw() returns null
- getpayload() returns part of tostring()?
- getpayload().getbody().getdata() returns null
- 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
Post a Comment