java.lang.Object
jakarta.mail.Message
jakarta.mail.internet.MimeMessage
org.eclipse.angus.mail.pop3.POP3Message
- All Implemented Interfaces:
MimePart
,Part
,ReadableMime
A POP3 Message. Just like a MimeMessage except that
some things are not supported.
-
Nested Class Summary
Nested classes/interfaces inherited from class jakarta.mail.internet.MimeMessage
MimeMessage.RecipientType
-
Field Summary
Fields inherited from class jakarta.mail.internet.MimeMessage
cachedContent, content, contentStream, dh, flags, headers, modified, saved
Fields inherited from interface jakarta.mail.Part
ATTACHMENT, INLINE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add this value to the existing values for this header_name.void
addHeaderLine
(String line) Add a raw RFC822 header-line.Get all header lines as an Enumeration of Strings.Return all the headers from this Message as an enumeration of Header objects.protected InputStream
Produce the raw bytes of the content.String[]
Get all the headers for this header_name.Get all the headers for this header name, returned as a single String, with headers separated by the delimiter.getMatchingHeaderLines
(String[] names) Get matching header lines as an Enumeration of Strings.getMatchingHeaders
(String[] names) Return matching headers from this Message as an Enumeration of Header objects.Return the MIME format stream corresponding to this message part.getNonMatchingHeaderLines
(String[] names) Get non-matching header lines as an Enumeration of Strings.getNonMatchingHeaders
(String[] names) Return non-matching headers from this Message as an Enumeration of Header objects.int
getSize()
Return the size of the content of this message in bytes.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.void
removeHeader
(String name) Remove all headers with this name.void
POP3 message can't be changed.void
Set the specified flags on this message to the specified value.void
Set the value for this header_name.top
(int n) Fetch the header of the message and the firstn
lines of the raw content of the message.void
writeTo
(OutputStream os, 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
Methods inherited from class jakarta.mail.Message
addRecipient, getFolder, getMessageNumber, getSession, isExpunged, match, setExpunged, setFlag, setMessageNumber, setRecipient
-
Constructor Details
-
POP3Message
- Throws:
MessagingException
-
-
Method Details
-
setFlags
Set the specified flags on this message to the specified value.- Overrides:
setFlags
in classMimeMessage
- Parameters:
newFlags
- the flags to be setset
- the value to be set- Throws:
IllegalWriteException
- if the underlying implementation does not support modificationMessagingException
- for other failures- See Also:
-
getSize
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 interfacePart
- Overrides:
getSize
in classMimeMessage
- Returns:
- size of content in bytes
- Throws:
MessagingException
- for failures
-
getContentStream
Produce the raw bytes of the content. The data is fetched using the POP3 RETR command.- Overrides:
getContentStream
in classMimeMessage
- Returns:
- an InputStream containing the raw bytes
- Throws:
MessagingException
- for failures- See Also:
-
getMimeStream
Return the MIME format stream corresponding to this message part.- Specified by:
getMimeStream
in interfaceReadableMime
- Returns:
- the MIME format stream
- Throws:
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. IfinvalidateHeaders
is true, invalidate the headers as well.- Parameters:
invalidateHeaders
- invalidate the headers as well?
-
top
Fetch the header of the message and the firstn
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
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 interfacePart
- Overrides:
getHeader
in classMimeMessage
- Parameters:
name
- name of header- Returns:
- array of headers
- Throws:
MessagingException
- for failures- See Also:
-
getHeader
Get 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:
getHeader
in interfaceMimePart
- Overrides:
getHeader
in classMimeMessage
- Parameters:
name
- the name of this headerdelimiter
- delimiter between returned headers- Returns:
- the value fields for all headers with this name
- Throws:
MessagingException
- for failures
-
setHeader
Set the value for this header_name. Throws IllegalWriteException because POP3 messages are read-only.- Specified by:
setHeader
in interfacePart
- Overrides:
setHeader
in classMimeMessage
- Parameters:
name
- header namevalue
- header value- Throws:
IllegalWriteException
- because the underlying implementation does not support modificationIllegalStateException
- if this message is obtained from a READ_ONLY folder.MessagingException
- for other failures- See Also:
-
addHeader
Add this value to the existing values for this header_name. Throws IllegalWriteException because POP3 messages are read-only.- Specified by:
addHeader
in interfacePart
- Overrides:
addHeader
in classMimeMessage
- Parameters:
name
- header namevalue
- header value- Throws:
IllegalWriteException
- because the underlying implementation does not support modificationIllegalStateException
- if this message is obtained from a READ_ONLY folder.MessagingException
- for other failures- See Also:
-
removeHeader
Remove all headers with this name. Throws IllegalWriteException because POP3 messages are read-only.- Specified by:
removeHeader
in interfacePart
- Overrides:
removeHeader
in classMimeMessage
- Parameters:
name
- the name of this header- Throws:
IllegalWriteException
- because the underlying implementation does not support modificationIllegalStateException
- if this message is obtained from a READ_ONLY folder.MessagingException
- for other failures
-
getAllHeaders
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 interfacePart
- Overrides:
getAllHeaders
in classMimeMessage
- Returns:
- array of header objects
- Throws:
MessagingException
- for failures- See Also:
-
getMatchingHeaders
Return matching headers from this Message as an Enumeration of Header objects.- Specified by:
getMatchingHeaders
in interfacePart
- Overrides:
getMatchingHeaders
in classMimeMessage
- Parameters:
names
- the headers to match- Returns:
- enumeration of Header objects
- Throws:
MessagingException
- for failures
-
getNonMatchingHeaders
Return non-matching headers from this Message as an Enumeration of Header objects.- Specified by:
getNonMatchingHeaders
in interfacePart
- Overrides:
getNonMatchingHeaders
in classMimeMessage
- Parameters:
names
- the headers to not match- Returns:
- enumeration of Header objects
- Throws:
MessagingException
- for failures
-
addHeaderLine
Add a raw RFC822 header-line. Throws IllegalWriteException because POP3 messages are read-only.- Specified by:
addHeaderLine
in interfaceMimePart
- Overrides:
addHeaderLine
in classMimeMessage
- Parameters:
line
- the line to add- Throws:
IllegalWriteException
- because the underlying implementation does not support modificationIllegalStateException
- if this message is obtained from a READ_ONLY folder.MessagingException
- for other failures
-
getAllHeaderLines
Get 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:
getAllHeaderLines
in interfaceMimePart
- Overrides:
getAllHeaderLines
in classMimeMessage
- Returns:
- an Enumeration of Strings
- Throws:
MessagingException
- for failures
-
getMatchingHeaderLines
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 interfaceMimePart
- Overrides:
getMatchingHeaderLines
in classMimeMessage
- Parameters:
names
- the headers to return- Returns:
- an Enumeration of Strings
- Throws:
MessagingException
- for failures
-
getNonMatchingHeaderLines
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 interfaceMimePart
- Overrides:
getNonMatchingHeaderLines
in classMimeMessage
- Parameters:
names
- the headers to not return- Returns:
- an Enumeration of Strings
- Throws:
MessagingException
- for failures
-
saveChanges
POP3 message can't be changed. This method throws IllegalWriteException.- Overrides:
saveChanges
in classMimeMessage
- Throws:
IllegalWriteException
- because the underlying implementation does not support modificationMessagingException
- for other failures
-
writeTo
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 classMimeMessage
- Parameters:
os
- the stream to write toignoreList
- the headers to not include in the output- Throws:
IOException
- if an error occurs writing to the stream or if an error is generated by the jakarta.activation layer.MessagingException
- for other failures- See Also:
-
DataHandler.writeTo(java.io.OutputStream)
-