Java Reference
In-Depth Information
Mailer m
=
new
new
Mailer
();
FileProperties props
=
new
new
FileProperties
(
MailConstants
.
PROPS_FILE_NAME
);
String serverHost
=
props
.
getProperty
(
MailConstants
.
SEND_HOST
);
iif
(
serverHost
==
null
null
) {
JOptionPane
.
showMessageDialog
(
parent
,
"\""
+
MailConstants
.
SEND_HOST
+
"\" must be set in properties"
,
"No server!"
,
JOptionPane
.
ERROR_MESSAGE
);
return
return
;
}
m
.
setServer
(
serverHost
);
String tmp
=
props
.
getProperty
(
MailConstants
.
SEND_DEBUG
);
m
.
setVerbose
(
tmp
!=
null
null
&&
tmp
.
equals
(
"true"
));
String myAddress
=
props
.
getProperty
(
"Mail.address"
);
iif
(
myAddress
==
null
null
) {
JOptionPane
.
showMessageDialog
(
parent
,
"\"Mail.address\" must be set in properties"
,
"No From: address!"
,
JOptionPane
.
ERROR_MESSAGE
);
return
return
;
}
m
.
setFrom
(
myAddress
);
m
.
setToList
(
toTF
.
getText
());
m
.
setCcList
(
ccTF
.
getText
());
// m.setBccList(bccTF.getText());
iif
(
subjectTF
.
getText
().
length
() !=
0
) {
m
.
setSubject
(
subjectTF
.
getText
());
}
// Now copy the text from the Compose TextArea.
m
.
setBody
(
msgText
.
getText
());
// XXX I18N: use setBody(msgText.getText(), charset)
// Finally, send the sucker!
m
.
doSend
();
// Now hide the main window
maybeKillParent
();