- java.lang.Object
-
- jakarta.mail.Message
-
- jakarta.mail.internet.MimeMessage
-
- org.eclipse.angus.mail.pop3.POP3Message
-
- All Implemented Interfaces:
jakarta.mail.internet.MimePart,jakarta.mail.Part,ReadableMime
public class POP3Message extends jakarta.mail.internet.MimeMessage implements ReadableMime
A POP3 Message. Just like a MimeMessage except that some things are not supported.
-
-
Constructor Summary
Constructors Constructor Description POP3Message(jakarta.mail.Folder folder, int msgno)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddHeader(java.lang.String name, java.lang.String value)Add this value to the existing values for this header_name.voidaddHeaderLine(java.lang.String line)Add a raw RFC822 header-line.java.util.Enumeration<java.lang.String>getAllHeaderLines()Get all header lines as an Enumeration of Strings.java.util.Enumeration<jakarta.mail.Header>getAllHeaders()Return all the headers from this Message as an enumeration of Header objects.protected java.io.InputStreamgetContentStream()Produce the raw bytes of the content.java.lang.String[]getHeader(java.lang.String name)Get all the headers for this header_name.java.lang.StringgetHeader(java.lang.String name, java.lang.String delimiter)Get all the headers for this header name, returned as a single String, with headers separated by the delimiter.java.util.Enumeration<java.lang.String>getMatchingHeaderLines(java.lang.String[] names)Get matching header lines as an Enumeration of Strings.java.util.Enumeration<jakarta.mail.Header>getMatchingHeaders(java.lang.String[] names)Return matching headers from this Message as an Enumeration of Header objects.java.io.InputStreamgetMimeStream()Return the MIME format stream corresponding to this message part.java.util.Enumeration<java.lang.String>getNonMatchingHeaderLines(java.lang.String[] names)Get non-matching header lines as an Enumeration of Strings.java.util.Enumeration<jakarta.mail.Header>getNonMatchingHeaders(java.lang.String[] names)Return non-matching headers from this Message as an Enumeration of Header objects.intgetSize()Return the size of the content of this message in bytes.voidinvalidate(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.voidremoveHeader(java.lang.String name)Remove all headers with this name.voidsaveChanges()POP3 message can't be changed.voidsetFlags(jakarta.mail.Flags newFlags, boolean set)Set the specified flags on this message to the specified value.voidsetHeader(java.lang.String name, java.lang.String value)Set the value for this header_name.java.io.InputStreamtop(int n)Fetch the header of the message and the firstnlines of the raw content of the message.voidwriteTo(java.io.OutputStream os, java.lang.String[] ignoreList)Output the message as an RFC 822 format stream, without specified headers.-
Methods inherited from class jakarta.mail.internet.MimeMessage
addFrom, addRecipients, addRecipients, createInternetHeaders, createMimeMessage, getAllRecipients, getContent, getContentID, getContentLanguage, getContentMD5, getContentType, getDataHandler, getDescription, getDisposition, getEncoding, getFileName, getFlags, getFrom, getInputStream, getLineCount, getMessageID, getRawInputStream, getReceivedDate, getRecipients, getReplyTo, getSender, getSentDate, getSubject, isMimeType, isSet, parse, reply, reply, setContent, setContent, setContentID, setContentLanguage, setContentMD5, setDataHandler, setDescription, setDescription, setDisposition, setFileName, setFrom, setFrom, setFrom, setRecipients, setRecipients, setReplyTo, setSender, setSentDate, setSubject, setSubject, setText, setText, setText, updateHeaders, updateMessageID, writeTo
-
-
-
-
Method Detail
-
setFlags
public void setFlags(jakarta.mail.Flags newFlags, boolean set) throws jakarta.mail.MessagingExceptionSet the specified flags on this message to the specified value.- Overrides:
setFlagsin classjakarta.mail.internet.MimeMessage- Parameters:
newFlags- the flags to be setset- the value to be set- Throws:
jakarta.mail.MessagingException
-
getSize
public int getSize() throws jakarta.mail.MessagingExceptionReturn 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:
getSizein interfacejakarta.mail.Part- Overrides:
getSizein classjakarta.mail.internet.MimeMessage- Returns:
- size of content in bytes
- Throws:
jakarta.mail.MessagingException- for failures
-
getContentStream
protected java.io.InputStream getContentStream() throws jakarta.mail.MessagingExceptionProduce the raw bytes of the content. The data is fetched using the POP3 RETR command.- Overrides:
getContentStreamin classjakarta.mail.internet.MimeMessage- Throws:
jakarta.mail.MessagingException- See Also:
MimeMessage.contentStream
-
getMimeStream
public java.io.InputStream getMimeStream() throws jakarta.mail.MessagingExceptionReturn the MIME format stream corresponding to this message part.- Specified by:
getMimeStreamin interfaceReadableMime- Returns:
- the MIME format stream
- Throws:
jakarta.mail.MessagingException- for failures- Since:
- JavaMail 1.4.5
-
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. IfinvalidateHeadersis true, invalidate the headers as well.- Parameters:
invalidateHeaders- invalidate the headers as well?
-
top
public java.io.InputStream top(int n) throws jakarta.mail.MessagingExceptionFetch the header of the message and the firstnlines 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:
jakarta.mail.MessagingException- for failures
-
getHeader
public java.lang.String[] getHeader(java.lang.String name) throws jakarta.mail.MessagingExceptionGet 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:
getHeaderin interfacejakarta.mail.Part- Overrides:
getHeaderin classjakarta.mail.internet.MimeMessage- Parameters:
name- name of header- Returns:
- array of headers
- Throws:
jakarta.mail.MessagingException- for failures- See Also:
MimeUtility
-
getHeader
public java.lang.String getHeader(java.lang.String name, java.lang.String delimiter) throws jakarta.mail.MessagingExceptionGet all the headers for this header name, returned as a single String, with headers separated by the delimiter. If the delimiter isnull, only the first header is returned.- Specified by:
getHeaderin interfacejakarta.mail.internet.MimePart- Overrides:
getHeaderin classjakarta.mail.internet.MimeMessage- Parameters:
name- the name of this headerdelimiter- delimiter between returned headers- Returns:
- the value fields for all headers with this name
- Throws:
jakarta.mail.MessagingException- for failures
-
setHeader
public void setHeader(java.lang.String name, java.lang.String value) throws jakarta.mail.MessagingExceptionSet the value for this header_name. Throws IllegalWriteException because POP3 messages are read-only.- Specified by:
setHeaderin interfacejakarta.mail.Part- Overrides:
setHeaderin classjakarta.mail.internet.MimeMessage- Parameters:
name- header namevalue- header value- Throws:
jakarta.mail.IllegalWriteException- because the underlying implementation does not support modificationjava.lang.IllegalStateException- if this message is obtained from a READ_ONLY folder.jakarta.mail.MessagingException- for other failures- See Also:
MimeUtility
-
addHeader
public void addHeader(java.lang.String name, java.lang.String value) throws jakarta.mail.MessagingExceptionAdd this value to the existing values for this header_name. Throws IllegalWriteException because POP3 messages are read-only.- Specified by:
addHeaderin interfacejakarta.mail.Part- Overrides:
addHeaderin classjakarta.mail.internet.MimeMessage- Parameters:
name- header namevalue- header value- Throws:
jakarta.mail.IllegalWriteException- because the underlying implementation does not support modificationjava.lang.IllegalStateException- if this message is obtained from a READ_ONLY folder.jakarta.mail.MessagingException- See Also:
MimeUtility
-
removeHeader
public void removeHeader(java.lang.String name) throws jakarta.mail.MessagingExceptionRemove all headers with this name. Throws IllegalWriteException because POP3 messages are read-only.- Specified by:
removeHeaderin interfacejakarta.mail.Part- Overrides:
removeHeaderin classjakarta.mail.internet.MimeMessage- Throws:
jakarta.mail.IllegalWriteException- because the underlying implementation does not support modificationjava.lang.IllegalStateException- if this message is obtained from a READ_ONLY folder.jakarta.mail.MessagingException
-
getAllHeaders
public java.util.Enumeration<jakarta.mail.Header> getAllHeaders() throws jakarta.mail.MessagingExceptionReturn 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:
getAllHeadersin interfacejakarta.mail.Part- Overrides:
getAllHeadersin classjakarta.mail.internet.MimeMessage- Returns:
- array of header objects
- Throws:
jakarta.mail.MessagingException- for failures- See Also:
MimeUtility
-
getMatchingHeaders
public java.util.Enumeration<jakarta.mail.Header> getMatchingHeaders(java.lang.String[] names) throws jakarta.mail.MessagingExceptionReturn matching headers from this Message as an Enumeration of Header objects.- Specified by:
getMatchingHeadersin interfacejakarta.mail.Part- Overrides:
getMatchingHeadersin classjakarta.mail.internet.MimeMessage- Throws:
jakarta.mail.MessagingException- for failures
-
getNonMatchingHeaders
public java.util.Enumeration<jakarta.mail.Header> getNonMatchingHeaders(java.lang.String[] names) throws jakarta.mail.MessagingExceptionReturn non-matching headers from this Message as an Enumeration of Header objects.- Specified by:
getNonMatchingHeadersin interfacejakarta.mail.Part- Overrides:
getNonMatchingHeadersin classjakarta.mail.internet.MimeMessage- Throws:
jakarta.mail.MessagingException- for failures
-
addHeaderLine
public void addHeaderLine(java.lang.String line) throws jakarta.mail.MessagingExceptionAdd a raw RFC822 header-line. Throws IllegalWriteException because POP3 messages are read-only.- Specified by:
addHeaderLinein interfacejakarta.mail.internet.MimePart- Overrides:
addHeaderLinein classjakarta.mail.internet.MimeMessage- Throws:
jakarta.mail.IllegalWriteException- because the underlying implementation does not support modificationjava.lang.IllegalStateException- if this message is obtained from a READ_ONLY folder.jakarta.mail.MessagingException
-
getAllHeaderLines
public java.util.Enumeration<java.lang.String> getAllHeaderLines() throws jakarta.mail.MessagingExceptionGet all 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:
getAllHeaderLinesin interfacejakarta.mail.internet.MimePart- Overrides:
getAllHeaderLinesin classjakarta.mail.internet.MimeMessage- Throws:
jakarta.mail.MessagingException- for failures
-
getMatchingHeaderLines
public java.util.Enumeration<java.lang.String> getMatchingHeaderLines(java.lang.String[] names) throws jakarta.mail.MessagingExceptionGet 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:
getMatchingHeaderLinesin interfacejakarta.mail.internet.MimePart- Overrides:
getMatchingHeaderLinesin classjakarta.mail.internet.MimeMessage- Throws:
jakarta.mail.MessagingException- for failures
-
getNonMatchingHeaderLines
public java.util.Enumeration<java.lang.String> getNonMatchingHeaderLines(java.lang.String[] names) throws jakarta.mail.MessagingExceptionGet 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:
getNonMatchingHeaderLinesin interfacejakarta.mail.internet.MimePart- Overrides:
getNonMatchingHeaderLinesin classjakarta.mail.internet.MimeMessage- Throws:
jakarta.mail.MessagingException- for failures
-
saveChanges
public void saveChanges() throws jakarta.mail.MessagingExceptionPOP3 message can't be changed. This method throws IllegalWriteException.- Overrides:
saveChangesin classjakarta.mail.internet.MimeMessage- Throws:
jakarta.mail.IllegalWriteException- because the underlying implementation does not support modificationjakarta.mail.MessagingException
-
writeTo
public void writeTo(java.io.OutputStream os, java.lang.String[] ignoreList) throws java.io.IOException, jakarta.mail.MessagingExceptionOutput 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:
writeToin classjakarta.mail.internet.MimeMessage- Throws:
java.io.IOException- if an error occurs writing to the stream or if an error is generated by the jakarta.activation layer.jakarta.mail.MessagingException- for other failures- See Also:
DataHandler.writeTo(java.io.OutputStream)
-
-