- 
- All Superinterfaces:
- Part
 - All Known Implementing Classes:
- MimeBodyPart,- MimeMessage,- PreencodedMimeBodyPart
 
 public interface MimePart extends Part The MimePart interface models an Entity as defined by MIME (RFC2045, Section 2.4).MimePart extends the Part interface to add additional RFC822 and MIME specific semantics and attributes. It provides the base interface for the MimeMessage and MimeBodyPart classes 
 A note on RFC822 and MIME headersRFC822 and MIME header fields must contain only US-ASCII characters. If a header contains non US-ASCII characters, it must be encoded as per the rules in RFC 2047. The MimeUtility class provided in this package can be used to to achieve this. Callers of the setHeader,addHeader, andaddHeaderLinemethods are responsible for enforcing the MIME requirements for the specified headers. In addition, these header fields must be folded (wrapped) before being sent if they exceed the line length limitation for the transport (1000 bytes for SMTP). Received headers may have been folded. The application is responsible for folding and unfolding headers as appropriate.- Author:
- John Mani
- See Also:
- MimeUtility,- Part
 
- 
- 
Field Summary- 
Fields inherited from interface jakarta.mail.PartATTACHMENT, INLINE
 
- 
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Modifier and Type Method Description 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.lang.StringgetContentID()Get the Content-ID of this part.java.lang.String[]getContentLanguage()Get the language tags specified in the Content-Language header of this MimePart.java.lang.StringgetContentMD5()Get the Content-MD5 digest of this part.java.lang.StringgetEncoding()Get the transfer encoding of this part.java.lang.StringgetHeader(java.lang.String name, java.lang.String delimiter)Get the values of all header fields available for this header, returned as a single String, with the values 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<java.lang.String>getNonMatchingHeaderLines(java.lang.String[] names)Get non-matching header lines as an Enumeration of Strings.voidsetContentLanguage(java.lang.String[] languages)Set the Content-Language header of this MimePart.voidsetContentMD5(java.lang.String md5)Set the Content-MD5 of this part.voidsetText(java.lang.String text)Convenience method that sets the given String as this part's content, with a MIME type of "text/plain".voidsetText(java.lang.String text, java.lang.String charset)Convenience method that sets the given String as this part's content, with a MIME type of "text/plain" and the specified charset.voidsetText(java.lang.String text, java.lang.String charset, java.lang.String subtype)Convenience method that sets the given String as this part's content, with a primary MIME type of "text" and the specified MIME subtype.- 
Methods inherited from interface jakarta.mail.PartaddHeader, getAllHeaders, getContent, getContentType, getDataHandler, getDescription, getDisposition, getFileName, getHeader, getInputStream, getLineCount, getMatchingHeaders, getNonMatchingHeaders, getSize, isMimeType, removeHeader, setContent, setContent, setDataHandler, setDescription, setDisposition, setFileName, setHeader, writeTo
 
- 
 
- 
- 
- 
Method Detail- 
getHeaderjava.lang.String getHeader(java.lang.String name, java.lang.String delimiter) throws MessagingExceptionGet the values of all header fields available for this header, returned as a single String, with the values separated by the delimiter. If the delimiter isnull, only the first value is returned.- Parameters:
- name- the name of this header
- delimiter- delimiter between fields in returned string
- Returns:
- the value fields for all headers with this name
- Throws:
- MessagingException- for failures
 
 - 
addHeaderLinevoid addHeaderLine(java.lang.String line) throws MessagingExceptionAdd a raw RFC822 header-line.- Parameters:
- line- the line to add
- Throws:
- IllegalWriteException- if the underlying implementation does not support modification
- java.lang.IllegalStateException- if this Part is obtained from a READ_ONLY folder
- MessagingException- for other failures
 
 - 
getAllHeaderLinesjava.util.Enumeration<java.lang.String> getAllHeaderLines() throws 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.- Returns:
- an Enumeration of Strings
- Throws:
- MessagingException- for failures
 
 - 
getMatchingHeaderLinesjava.util.Enumeration<java.lang.String> getMatchingHeaderLines(java.lang.String[] names) throws 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.- Parameters:
- names- the headers to return
- Returns:
- an Enumeration of Strings
- Throws:
- MessagingException- for failures
 
 - 
getNonMatchingHeaderLinesjava.util.Enumeration<java.lang.String> getNonMatchingHeaderLines(java.lang.String[] names) throws 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.- Parameters:
- names- the headers to not return
- Returns:
- an Enumeration of Strings
- Throws:
- MessagingException- for failures
 
 - 
getEncodingjava.lang.String getEncoding() throws MessagingExceptionGet the transfer encoding of this part.- Returns:
- content-transfer-encoding
- Throws:
- MessagingException- for failures
 
 - 
getContentIDjava.lang.String getContentID() throws MessagingExceptionGet the Content-ID of this part. Returns null if none present.- Returns:
- content-ID
- Throws:
- MessagingException- for failures
 
 - 
getContentMD5java.lang.String getContentMD5() throws MessagingExceptionGet the Content-MD5 digest of this part. Returns null if none present.- Returns:
- content-MD5
- Throws:
- MessagingException- for failures
 
 - 
setContentMD5void setContentMD5(java.lang.String md5) throws MessagingExceptionSet the Content-MD5 of this part.- Parameters:
- md5- the MD5 value
- Throws:
- IllegalWriteException- if the underlying implementation does not support modification
- java.lang.IllegalStateException- if this Part is obtained from a READ_ONLY folder
- MessagingException
 
 - 
getContentLanguagejava.lang.String[] getContentLanguage() throws MessagingExceptionGet the language tags specified in the Content-Language header of this MimePart. The Content-Language header is defined by RFC 1766. Returnsnullif this header is not available.- Returns:
- array of content language strings
- Throws:
- MessagingException- for failures
 
 - 
setContentLanguagevoid setContentLanguage(java.lang.String[] languages) throws MessagingExceptionSet the Content-Language header of this MimePart. The Content-Language header is defined by RFC1766.- Parameters:
- languages- array of language tags
- Throws:
- IllegalWriteException- if the underlying implementation does not support modification
- java.lang.IllegalStateException- if this Part is obtained from a READ_ONLY folder
- MessagingException
 
 - 
setTextvoid setText(java.lang.String text) throws MessagingExceptionConvenience method that sets the given String as this part's content, with a MIME type of "text/plain". If the string contains non US-ASCII characters. it will be encoded using the platform's default charset. The charset is also used to set the "charset" parameter.Note that there may be a performance penalty if textis large, since this method may have to scan all the characters to determine what charset to use.If the charset is already known, use the setTextmethod that takes the charset parameter.- Specified by:
- setTextin interface- Part
- Parameters:
- text- the text content to set
- Throws:
- MessagingException- if an error occurs
- See Also:
- setText(String text, String charset)
 
 - 
setTextvoid setText(java.lang.String text, java.lang.String charset) throws MessagingExceptionConvenience method that sets the given String as this part's content, with a MIME type of "text/plain" and the specified charset. The given Unicode string will be charset-encoded using the specified charset. The charset is also used to set "charset" parameter.- Parameters:
- text- the text content to set
- charset- the charset to use for the text
- Throws:
- MessagingException- if an error occurs
 
 - 
setTextvoid setText(java.lang.String text, java.lang.String charset, java.lang.String subtype) throws MessagingExceptionConvenience method that sets the given String as this part's content, with a primary MIME type of "text" and the specified MIME subtype. The given Unicode string will be charset-encoded using the specified charset. The charset is also used to set the "charset" parameter.- Parameters:
- text- the text content to set
- charset- the charset to use for the text
- subtype- the MIME subtype to use (e.g., "html")
- Throws:
- MessagingException- if an error occurs
 
 
- 
 
-