Java Reference
In-Depth Information
Example 17-6. email/MailConstants.java
/** Simple list of Properties keys for the Mail System. */
public
public class
class
MailConstants
MailConstants
{
public
public static
static final
final
String PROPS_FILE_NAME
=
"MailClient.properties"
;
public
public static
static final
final
String SEND_PROTO
=
"Mail.send.protocol"
;
public
public static
static final
final
String SEND_USER
=
"Mail.send.user"
;
public
public static
static final
final
String SEND_PASS
=
"Mail.send.password"
;
public
public static
static final
final
String SEND_ROOT
=
"Mail.send.root"
;
public
public static
static final
final
String SEND_HOST
=
"Mail.send.host"
;
public
public static
static final
final
String SEND_DEBUG
=
"Mail.send.debug"
;
public
public static
static final
final
String RECV_PROTO
=
"Mail.receive.protocol"
;
public
public static
static final
final
String RECV_PORT
=
"Mail.receive.port"
;
public
public static
static final
final
String RECV_USER
=
"Mail.receive.user"
;
public
public static
static final
final
String RECV_PASS
=
"Mail.receive.password"
;
public
public static
static final
final
String RECV_ROOT
=
"Mail.receive.root"
;
public
public static
static final
final
String RECV_HOST
=
"Mail.receive.host"
;
public
public static
static final
final
String RECV_DEBUG
=
"Mail.receive.debug"
;
}
The fields in this class can be referred to by their full names—for example,
MailCon-
stants.RECV_PROTO
. However, that is almost as much typing as the original long string
(
Mail.receive.protocol
). As a shortcut, programs that use more than a few of the fields
will want to use the
static import
mechanism, and then can refer to the fields as part of
Reading Email
Problem
You need to read electronic mail in a program.
Solution
Use a JavaMail
Store
.