Class GmailMessage

  • All Implemented Interfaces:
    ReadableMime, MimePart, Part

    public class GmailMessage
    extends IMAPMessage
    A Gmail message. Adds methods to access Gmail-specific per-message data.
    Since:
    JavaMail 1.4.6
    Author:
    Bill Shannon
    • Constructor Detail

      • GmailMessage

        protected GmailMessage​(IMAPFolder folder,
                               int msgnum)
        Constructor.
        Parameters:
        folder - the containing folder
        msgnum - the message sequence number
      • GmailMessage

        protected GmailMessage​(Session session)
        Constructor, for use by IMAPNestedMessage.
        Parameters:
        session - the Session
    • Method Detail

      • getLabels

        public java.lang.String[] getLabels()
                                     throws MessagingException
        Return the Gmail labels associated with this message.
        Returns:
        array of labels, or empty array if none
        Throws:
        MessagingException - for failures
      • setLabels

        public void setLabels​(java.lang.String[] labels,
                              boolean set)
                       throws MessagingException
        Set/Unset the given labels on this message.
        Parameters:
        labels - the labels to add or remove
        set - true to add labels, false to remove
        Throws:
        MessagingException - for failures
        Since:
        JavaMail 1.5.5
      • clearCachedLabels

        public void clearCachedLabels()
        Clear any cached labels for this message. The Gmail labels for a messge will be cached when first accessed using either the fetch method or the getLabels method. Gmail provides no notification when the labels have been changed by another application so applications may need to clear the cache if accessing the labels for a message more than once while the Folder is open.
        Since:
        JavaMail 1.5.6