Package javax.mail.internet
Interface MimePart
-
- All Superinterfaces:
Part
- All Known Implementing Classes:
IMAPBodyPart,IMAPMessage,MaildirMessage,MboxMessage,MimeBodyPart,MimeMessage,NNTPMessage,POP3Message,gnu.mail.providers.ReadOnlyMessage
public interface MimePart extends Part
A MIME part is an Entity as defined by MIME (RFC2045, Section 2.4).The string representation of RFC822 and MIME header fields must contain only US-ASCII characters. Non US-ASCII characters must be encoded as per the rules in RFC 2047. This class does not enforce those rules; the caller is expected to use
MimeUtilityto ensure that header values are correctly encoded.- Version:
- 1.4
- Author:
- Chris Burdess
-
-
Field Summary
-
Fields inherited from interface javax.mail.Part
ATTACHMENT, INLINE
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddHeaderLine(java.lang.String line)Adds an RFC822 header-line.java.util.EnumerationgetAllHeaderLines()Returns all the header-lines.java.lang.StringgetContentID()Returns the value of the Content-ID header field of this part.java.lang.String[]getContentLanguage()Returns the languages specified in the Content-Language header of this part, as defined by RFC 1766.java.lang.StringgetContentMD5()Returns the value of the Content-MD5 header field of this part.java.lang.StringgetEncoding()Returns the value of the Content-Transfer-Encoding header field of this part.java.lang.StringgetHeader(java.lang.String header_name, java.lang.String delimiter)Returns the values of all header fields for the specified name, returned as a single String with the values separated by the given delimiter.java.util.EnumerationgetMatchingHeaderLines(java.lang.String[] names)Returns all the header-lines with any of the given names.java.util.EnumerationgetNonMatchingHeaderLines(java.lang.String[] names)Returns all the header-lines without any of the given names.voidsetContentLanguage(java.lang.String[] languages)Sets the Content-Language header of this part.voidsetContentMD5(java.lang.String md5)Sets the Content-MD5 header value for this part.voidsetText(java.lang.String text)Sets the content of this message using the specified text, and with a MIME type of "text/plain".voidsetText(java.lang.String text, java.lang.String charset)Sets the content of this message using the specified text, and with a MIME type of "text/plain".voidsetText(java.lang.String text, java.lang.String charset, java.lang.String subtype)Sets the content of this message using the specified text, and with a text MIME type of the specified subtype.-
Methods inherited from interface javax.mail.Part
addHeader, 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
-
getHeader
java.lang.String getHeader(java.lang.String header_name, java.lang.String delimiter) throws MessagingExceptionReturns the values of all header fields for the specified name, returned as a single String with the values separated by the given delimiter. If the delimiter is null, only the first value is returned.- Parameters:
header_name- the header name- Throws:
MessagingException
-
addHeaderLine
void addHeaderLine(java.lang.String line) throws MessagingExceptionAdds an RFC822 header-line.- Throws:
IllegalWriteException- if the underlying implementation does not support modificationjava.lang.IllegalStateException- if this part is obtained from a READ_ONLY folderMessagingException
-
getAllHeaderLines
java.util.Enumeration getAllHeaderLines() throws MessagingExceptionReturns all the header-lines.- Returns:
- an Enumeration of Strings
- Throws:
MessagingException
-
getMatchingHeaderLines
java.util.Enumeration getMatchingHeaderLines(java.lang.String[] names) throws MessagingExceptionReturns all the header-lines with any of the given names.- Returns:
- an Enumeration of Strings
- Throws:
MessagingException
-
getNonMatchingHeaderLines
java.util.Enumeration getNonMatchingHeaderLines(java.lang.String[] names) throws MessagingExceptionReturns all the header-lines without any of the given names.- Returns:
- an Enumeration of Strings
- Throws:
MessagingException
-
getEncoding
java.lang.String getEncoding() throws MessagingExceptionReturns the value of the Content-Transfer-Encoding header field of this part.- Throws:
MessagingException
-
getContentID
java.lang.String getContentID() throws MessagingExceptionReturns the value of the Content-ID header field of this part.- Throws:
MessagingException
-
getContentMD5
java.lang.String getContentMD5() throws MessagingExceptionReturns the value of the Content-MD5 header field of this part.- Throws:
MessagingException
-
setContentMD5
void setContentMD5(java.lang.String md5) throws MessagingExceptionSets the Content-MD5 header value for this part.- Parameters:
IllegalStateException- if this part is obtained from a READ_ONLY folder- Throws:
IllegalWriteException- if the underlying implementation does not support modificationMessagingException
-
getContentLanguage
java.lang.String[] getContentLanguage() throws MessagingExceptionReturns the languages specified in the Content-Language header of this part, as defined by RFC 1766. This method returnsnullif this header is not available.- Throws:
MessagingException
-
setContentLanguage
void setContentLanguage(java.lang.String[] languages) throws MessagingExceptionSets the Content-Language header of this part.- Parameters:
languages- the array of language tags- Throws:
IllegalWriteException- if the underlying implementation does not support modificationjava.lang.IllegalStateException- if this Part is obtained from a READ_ONLY folderMessagingException
-
setText
void setText(java.lang.String text) throws MessagingExceptionSets the content of this message using the specified text, and with a MIME type of "text/plain".If the string contains non US-ASCII characters, it will be encoded using the platform default charset.
- Specified by:
setTextin interfacePart- Parameters:
text- the text content- Throws:
IllegalWriteException- if the underlying implementation does not support modificationMessagingException
-
setText
void setText(java.lang.String text, java.lang.String charset) throws MessagingExceptionSets the content of this message using the specified text, and with a MIME type of "text/plain".If the string contains non US-ASCII characters, it will be encoded using the specified charset.
- Parameters:
text- the text contentcharset- the charset to use for any encoding- Throws:
MessagingException
-
setText
void setText(java.lang.String text, java.lang.String charset, java.lang.String subtype) throws MessagingExceptionSets the content of this message using the specified text, and with a text MIME type of the specified subtype.If the string contains non US-ASCII characters, it will be encoded using the specified charset.
- Parameters:
text- the text contentcharset- the charset to use for any encodingsubtype- the MIME text subtype (e.g. "plain", "html")- Throws:
MessagingException- Since:
- JavaMail 1.4
-
-