Home > Back-end >  Javax Mail Gmail Add Custom Label
Javax Mail Gmail Add Custom Label

Time:06-24

I found some sources to read mails from gmail like: https://javahowtos.com/guides/127-libraries/366-how-to-read-gmail-using-java-and-javax-mail.html

It works super but I want to add label when I read the mail. You know that we can add labels in gmail https://support.google.com/mail/answer/118708?hl=en&co=GENIE.Platform=Desktop

Is it possible with javax mail?

CodePudding user response:

Used gmap to solve it: https://mvnrepository.com/artifact/com.sun.mail/gimap

GmailMessage gmsg = (GmailMessage) message;
gmsg.setLabels(new String[]{"Label1"}, true);
  • Related