Module jakarta.mail

Class POP3Message

    • Method Detail

      • getSize

        public int getSize()
                    throws MessagingException
        Return the size of the content of this message in bytes. Returns -1 if the size cannot be determined.

        Note that this number may not be an exact measure of the content size and may or may not account for any transfer encoding of the content.

        Specified by:
        getSize in interface Part
        Overrides:
        getSize in class MimeMessage
        Returns:
        size of content in bytes
        Throws:
        MessagingException - for failures
      • invalidate

        public void invalidate​(boolean invalidateHeaders)
        Invalidate the cache of content for this message object, causing it to be fetched again from the server the next time it is needed. If invalidateHeaders is true, invalidate the headers as well.
        Parameters:
        invalidateHeaders - invalidate the headers as well?
      • top

        public java.io.InputStream top​(int n)
                                throws MessagingException
        Fetch the header of the message and the first n lines of the raw content of the message. The headers and data are available in the returned InputStream.
        Parameters:
        n - number of lines of content to fetch
        Returns:
        InputStream containing the message headers and n content lines
        Throws:
        MessagingException - for failures
      • getHeader

        public java.lang.String[] getHeader​(java.lang.String name)
                                     throws MessagingException
        Get all the headers for this header_name. Note that certain headers may be encoded as per RFC 2047 if they contain non US-ASCII characters and these should be decoded.

        Specified by:
        getHeader in interface Part
        Overrides:
        getHeader in class MimeMessage
        Parameters:
        name - name of header
        Returns:
        array of headers
        Throws:
        MessagingException - for failures
        See Also:
        MimeUtility
      • getHeader

        public java.lang.String getHeader​(java.lang.String name,
                                          java.lang.String delimiter)
                                   throws MessagingException
        Get all the headers for this header name, returned as a single String, with headers separated by the delimiter. If the delimiter is null, only the first header is returned.
        Specified by:
        getHeader in interface MimePart
        Overrides:
        getHeader in class MimeMessage
        Parameters:
        name - the name of this header
        delimiter - delimiter between returned headers
        Returns:
        the value fields for all headers with this name
        Throws:
        MessagingException - for failures
      • setHeader

        public void setHeader​(java.lang.String name,
                              java.lang.String value)
                       throws MessagingException
        Set the value for this header_name. Throws IllegalWriteException because POP3 messages are read-only.
        Specified by:
        setHeader in interface Part
        Overrides:
        setHeader in class MimeMessage
        Parameters:
        name - header name
        value - header value
        Throws:
        IllegalWriteException - because the underlying implementation does not support modification
        java.lang.IllegalStateException - if this message is obtained from a READ_ONLY folder.
        MessagingException - for other failures
        See Also:
        MimeUtility
      • addHeader

        public void addHeader​(java.lang.String name,
                              java.lang.String value)
                       throws MessagingException
        Add this value to the existing values for this header_name. Throws IllegalWriteException because POP3 messages are read-only.
        Specified by:
        addHeader in interface Part
        Overrides:
        addHeader in class MimeMessage
        Parameters:
        name - header name
        value - header value
        Throws:
        IllegalWriteException - because the underlying implementation does not support modification
        java.lang.IllegalStateException - if this message is obtained from a READ_ONLY folder.
        MessagingException - for other failures
        See Also:
        MimeUtility
      • removeHeader

        public void removeHeader​(java.lang.String name)
                          throws MessagingException
        Remove all headers with this name. Throws IllegalWriteException because POP3 messages are read-only.
        Specified by:
        removeHeader in interface Part
        Overrides:
        removeHeader in class MimeMessage
        Parameters:
        name - the name of this header
        Throws:
        IllegalWriteException - because the underlying implementation does not support modification
        java.lang.IllegalStateException - if this message is obtained from a READ_ONLY folder.
        MessagingException - for other failures
      • getAllHeaders

        public java.util.Enumeration<Header> getAllHeaders()
                                                    throws MessagingException
        Return all the headers from this Message as an enumeration of Header objects.

        Note that certain headers may be encoded as per RFC 2047 if they contain non US-ASCII characters and these should be decoded.

        Specified by:
        getAllHeaders in interface Part
        Overrides:
        getAllHeaders in class MimeMessage
        Returns:
        array of header objects
        Throws:
        MessagingException - for failures
        See Also:
        MimeUtility
      • addHeaderLine

        public void addHeaderLine​(java.lang.String line)
                           throws MessagingException
        Add a raw RFC822 header-line. Throws IllegalWriteException because POP3 messages are read-only.
        Specified by:
        addHeaderLine in interface MimePart
        Overrides:
        addHeaderLine in class MimeMessage
        Parameters:
        line - the line to add
        Throws:
        IllegalWriteException - because the underlying implementation does not support modification
        java.lang.IllegalStateException - if this message is obtained from a READ_ONLY folder.
        MessagingException - for other failures
      • getMatchingHeaderLines

        public java.util.Enumeration<java.lang.String> getMatchingHeaderLines​(java.lang.String[] names)
                                                                       throws MessagingException
        Get matching header lines as an Enumeration of Strings. A Header line is a raw RFC822 header-line, containing both the "name" and "value" field.
        Specified by:
        getMatchingHeaderLines in interface MimePart
        Overrides:
        getMatchingHeaderLines in class MimeMessage
        Parameters:
        names - the headers to return
        Returns:
        an Enumeration of Strings
        Throws:
        MessagingException - for failures
      • getNonMatchingHeaderLines

        public java.util.Enumeration<java.lang.String> getNonMatchingHeaderLines​(java.lang.String[] names)
                                                                          throws MessagingException
        Get non-matching header lines as an Enumeration of Strings. A Header line is a raw RFC822 header-line, containing both the "name" and "value" field.
        Specified by:
        getNonMatchingHeaderLines in interface MimePart
        Overrides:
        getNonMatchingHeaderLines in class MimeMessage
        Parameters:
        names - the headers to not return
        Returns:
        an Enumeration of Strings
        Throws:
        MessagingException - for failures
      • writeTo

        public void writeTo​(java.io.OutputStream os,
                            java.lang.String[] ignoreList)
                     throws java.io.IOException,
                            MessagingException
        Output the message as an RFC 822 format stream, without specified headers. If the property "mail.pop3.cachewriteto" is set to "true", and ignoreList is null, and the message hasn't already been cached as a side effect of other operations, the message content is cached before being written. Otherwise, the message is streamed directly to the output stream without being cached.
        Overrides:
        writeTo in class MimeMessage
        Parameters:
        os - the stream to write to
        ignoreList - the headers to not include in the output
        Throws:
        java.io.IOException - if an error occurs writing to the stream or if an error is generated by the javax.activation layer.
        MessagingException - for other failures
        See Also:
        DataHandler.writeTo(java.io.OutputStream)