JavaMail Section Index | Page 3
What string do I pass to SimpleDateFormat to format the message date to spec - getSentDate() method of Message?
There is no need to create a custom DateFormat. The MailDateFormat class found in the javax.mail.internet handles all this for you. It formats and parses the date based on the draft-ietf-drums-msg...more
How is JavaMail licensed?
As of July 2005, JavaMail is licensed with GlassFish under Sun's CDDL open source license.
What is GlassFish?
The GlassFish Project is Sun's open source application server project. Found at https://glassfish.dev.java.net/, you can participate in the development of the latest version of Sun's Java System A...more
What version of JavaMail does GlassFish contain?
According to Bill Shannon of Sun, the July 2005 release of GlassFish contains JAF 1.1ea and a version of JavaMail slightly newer than 1.3.3ea.
How do I find out the number of deleted messages in a folder?
Added with JavaMail 1.3, the getDeletedMessageCount() method of Folder gets this for you. A -1 may be returned if the server doesn't support the operation.
How do I get the sender of an email?
The getFrom() of Message is one way, but the getSender() method of MimeMessage reads the RFC 822 Sender header field. A value of null is returned if the header isn't present. Comparing the two all...more
How do I set the default character encoding for JavaMail to use?
The mail.mime.charset system property is used. If unset, file.encoding is used instead.
How do I calculate the size of an entire folder?
For POP3, you can get this information for the INBOx with <size=2>com.sun.mail.pop3.POP3Folder.getSize()</size>.
For IMAP, the protocol doesn't support this feature. You would need to ...more
How do I package a JavaMail application into a single jar file along with the mail.jar and activation.jar?
You need to unjar all the JAR files into a single directory tree and then JAR them back up. The trick is preserving the location of some files:
425 Fri Dec 01 00:05:16 EST 2000 META-INF/javam...more
How do I get rid of unused connections? Doing something like checking for the existance of an IMAP folder leaves the connection open.
You can set the connection pool timeout property (mail.imap.connectionpooltimeout for imap). Then... according to JavaMail architect Bill Shannon:
Because JavaMail doesn't use a separate thread t...more
How do I find out if an IMAP server supports a particular capability?
If you have a folder open, you can do this:
import com.sun.mail.imap.IMAPFolder;
import com.sun.mail.imap.protocol.IMAPProtocol;
IMAPProtocol p = ((IMAPFolder)folder).getProtocol();
...more
Where can I find a regular expression to validate an email address?
One is available at http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html.
How do I configure JavaMail to work through my proxy server?
Proxy servers redirect HTTP connections, not JavaMail connections. In order to connect from behind a firewall for POP3, IMAP, and SMTP access, you need to connect to a SOCKS server. Your sys admin...more
How do I get the size of a message that I am going to send? The getSize() method works fine with received message but returns -1 if I use it with a message that I am going to send!
Get the InputStream for the message with getInputStream() and count the bytes.
What's new in JavaMail 1.3.1?
JavaMail 1.3.1 includes over 20 bug fixes, as well as support for
DIGEST-MD5 authentication in the SMTP provider (courtesy of Dean
Gibson).