Skip to main content

Posts

Showing posts with the label Read

Want to read something of your gmail (not only subject but body content too) using javax Lib?

Want to read something of your Gmail (not only subject but body content too) using javax Lib? For contentBody where MimeType is "text/plain" i.e. it's a plain text message, it works straight forward by using getContent() method but in case you have contentBody MimeType= text/html i.e. the message body only in HTML, you need to take care of Multipart for multipart/alternative and multipart/mixed based on your requirements. Here's the working code: Note * You still need to tweak the code based on your requirements like if there are more than 1 unread or read emails having the same subject that you are trying to look for in the subject like by setting Flags.Flag.DELETED=True before reading this new email or using Flags.Flag.RECENT=True. You may need to enable less secure apps to use JavaMail with Gmail: https://myaccount.google.com/lesssecureapps // userName is your gmail userName // password is your gmail password // subjectToContains is what you need to lo