Java Reference
In-Depth Information
System
.
exit
(
1
);
}
inbox
.
open
(
Folder
.
READ_ONLY
);
// Get the messages from the server
Message
[]
messages
=
inbox
.
getMessages
();
for
(
int
i
=
0
;
i
<
messages
.
length
;
i
++)
{
System
.
out
.
println
(
"------------ Message "
+
(
i
+
1
)
+
" ------------"
);
messages
[
i
].
writeTo
(
System
.
out
);
}
// Close the connection
// but don't remove the messages from the server
inbox
.
close
(
false
);
store
.
close
();
}
catch
(
MessagingException
|
IOException
ex
)
{
ex
.
printStackTrace
();
}
}
}
Here's some sample output I got when I pointed it at an account I don't use much:
$
java POP3Client
------------ Message 1 ------------
Received: (from eharold@localhost)
by utopia.poly.edu (8.8.8/8.8.8) id QAA05728
for eharold; Mon, 30 Nov 2009 16:14:29 -0500 (EST)
Date: Mon, 30 Nov 2009 16:14:29 -0500 (EST)
From: Elliotte Harold <eharold@utopia.poly.edu>
Message-Id: <200911302114.QAA05728@utopia.poly.edu>
To: eharold@utopia.poly.edu
Subject: test
Content-Type: text
X-UIDL: 87e3f1ba71738c8f772b15e3933241f0
Status: RO
hello you
------------ Message 2 ------------
Received: from russian.cloud9.net (russian.cloud9.net [
.4])
by utopia.poly.edu (8.8.8/8.8.8) with ESMTP id OAA28428
for <eharold@utopia.poly.edu>; Tue, 1 Dec 2009 14:05:06 -0500 (
Received: from [168.100.203.234] (macfaq.dialup.cloud9.net [168.100.203
by russian.cloud9.net (Postfix) with ESMTP id 24B93764F
for <eharold@utopia.poly.edu>; Tue, 1 Dec 2009 14:02:50 -0500
Mime-Version: 1.0
X-Sender: macfaq@mail.cloud9.net
Message-Id: <v04210100b46b1f97969d@[168.100.203.234]>
Date: Tue, 1 Dec 2009 13:55:40 -0500
To: eharold@utopia.poly.edu