Java Reference
In-Depth Information
%
java AttributeClient imap://elharo@mail.ibiblio.org/INBOX
------------ Message 1 ------------
From: "Richman, Jeremy" <jrichman@hq.ileaf.com>
To: 'xsl-list' <XSL-List@mulberrytech.com>
Subject: Re: New twist: eliminating nodes with duplicate content
Sent: Thu Dec 06 08:37:51 PST 2012
This message is approximately 3391 bytes long.
This message has approximately 87 lines.
------------ Message 2 ------------
From: schererm@us.ibm.com
To: Unicode List <unicode@unicode.org>
Subject: Re: Number ordering
Sent: Thu Dec 06 11:00:28 PST 2012
This message is approximately 1554 bytes long.
This message has approximately 18 lines.
------------ Message 3 ------------
From: John Posner <jjp@connix.com>
To: 'Nakita Watson' <nakita@oreilly.com>
Subject: RE: Another conference Call
Sent: Thu Dec 06 11:16:38 PST 2012
This message is approximately 1398 bytes long.
This message has approximately 19 lines.
Headers
Classes that implement the
Part
interface—for example,
Message
—generally declare
methods to return specific headers such as To: or From:. The
Part
interface, by contrast,
declares methods to get and set arbitrary headers regardless of name.
The
getHeader()
method gets the values of all the headers with a name that matches
the
name
argument. Some headers such as Received: can have multiple values and can
be included in a message multiple times, so this method returns those values as an array
of strings. It returns
null
if no header with that name is present in this
Part
:
public
String
[]
getHeader
(
String
name
)
throws
MessagingException
The
setHeader()
method adds a new header to an outgoing message:
public
void
setHeader
(
String
name
,
String
value
)
throws
MessagingException
,
IllegalWriteException
,
IllegalStateException
If there's already a header with this name, that header is deleted and the new one inserted
in its place—unless the folder in which the message resides is read-only, in which case
an
IllegalStateException
is thrown.
By contrast, the
addHeader()
method adds a header with the specified name without
replacing any that already exist: