Java Reference
In-Depth Information
The
getContentID()
method returns a string that uniquely identifies this part as given
content ID:
public
String
getContentID
()
throws
MessagingException
IllegalWriteException
,
IllegalStateException
The
getContentLanguage()
method returns the value of the Content-language: header.
This is a comma-separated list of two (or more) letter abbreviations for languages, as
defined by RFC 1766. For example, English is “en” and French is “fr”. It returns
null
if
the part doesn't have a Content-language: header.
public
String
[]
getContentLanguage
()
throws
MessagingException
There's also a
setContentLanguage()
method that you might use when sending a mes‐
sage:
public
void
setContentLanguage
(
String
[]
languages
)
throws
MessagingException
,
IllegalWriteException
,
IllegalStateException
Finally, the two
setText()
methods set the content of the part with the MIME type
text/plain
. The second
setText()
method also lets you specify the character set—for
example, us-ascii or ISO 8859-1:
public
void
setText
(
String
text
)
throws
MessagingException
public
void
setText
(
String
text
,
String
charset
)
throws
MessagingException
public
void
setText
(
String
text
,
String
charset
,
String
subtype
)
throws
MessagingException
In practice, a number of mail systems and libraries, especially Japanese ones, do not
correctly implement every detail of the relevant specifications. Consequently the Java‐
Mail API recognizes a number of system properties that control exactly how strictly
various rules are followed.
Table 7-1
lists the various system properties that control
MIME parsing. With a couple of exceptions the default values provide standards con‐
formant behavior, and changing these breaks conformance to work better with some
mail agents encountered in the wild.