Skip to main content

Posts

Showing posts with the label gmail

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...

javax.mail APIs Auth fail error for Gmail

If you are using javax.mail APIs and provided correct credentials for your Gmail account and still getting “javax.mail.AuthenticationFailedException: [AUTHENTICATIONFAILED] Invalid credentials (Failure)” error then there are high chances that you might have forgotten to relax the security of your Gmail account. You can use this link to allow less secure apps to access your Gmail (which obviously makes your account vulnerable and thus isn’t recommended) https://myaccount.google.com/lesssecureapps?pli=1