JavaMail Section Index
When using getMessagesByUID(long start, long end) to fetch a range of messages by UID, how to I specify the last available UID?
The UIDFolder class has a LASTUID constant for just such a purpose.
What causes an "javax.activation.UnsupportedDataTypeException: no object DCH for MIME type xxx/xxxx javax.mail.MessagingException: IOException while sending message;" to be sent and how do I fix this? [This happens for known MIME types like text/html.]
The Java Activation Framework used by JavaMail is not configured correctly.
It doesn't know how to handle the text/html content type.
An html handler is provided in JavaMail 1.1.3 but the mailc...more
If the attachment filename includes non-ASCII characters, how do I encode the name so that the name comes across appropriately?
You need to get the string as bytes and then encode the filename yoruself. In addition, you have to do the same for the content type and disposition:
String name = new String(fileName.getBytes())...more
How can I send a message to a folder other then the Inbox?
The sender of a message has no control over what folder the message gets saved in. All new messages appear in Inbox. The recipient's mail server either has to move them, or when the recipient fetc...more
How do I convert a comma delimeted string of email addresses to an array of recipients for a message?
Use the InternetAddress.parse() method:
String strName = /* request.getParameter("TO"); */
InternetAddress[] address = InternetAddress.parse(strName);
message.setRecipients(Message.Recipien...more
How do I set the character set (charset) for a content type?
You can set the content type of your message like:
msg.setContent(message,"text/html;charset="UTF-8"");
When I fetch messages from a UIDFolder via the getMessagesByUID() method, are they returned in any particular order?
The getMessagesByUID(long[] uids) version will return the messages in the order of the UIDs in the array. If one particular UID is invalid, null will be in the returned array. For the getMessagesB...more
Can my JavaMail client choose the authentication mechanism used on the server?
With the 1.4 JavaMail SMTP provider, you cannot. It will choose the first available mechanism, searching for either LOGIN, PLAIN, or DIGEST-MD5 in that
order.
How can I read a vCard attachment from my Java program?
The vCard4J SourceForge project (http://sourceforge.net/projects/vcard4j) offers just what you are looking for.
Does JavaMail support direct access to Microsoft Exchange contact lists and calendar appointments?
No. But, the Java Exchange Connector, available from http://jec.zapto.org/, is one commercial option that offers such access.
How do I manually set the mime type for an attached file?
You'll need to subclass FileDataSource and override its getContentType() method to return your desired type.
FileDataSource doesn't know about many mime types and seems to make most attachments application/octet-stream. How can I extend its mime type set?
You can add support for more extensions programmatically or by adding a META-INF/mime.types configuration file to your application.
For example, to map the .doc extension to the MIME type applic...more
I seem to have conflicting versions of JavaMail libraries in my CLASSPATH, but there seems to be only one. What's up?
The JavaMail libraries are a standard part of J2EE and thus every application server. Be sure you DO NOT have a second copy in your CLASSPATH, as it will conflict with that of the server. Check wi...more
I seem to have conflicting versions of JavaMail libraries in my CLASSPATH, but there seems to be only one. What's up?
The JavaMail libraries are a standard part of J2EE and thus every application server. Be sure you DO NOT have a second copy in your CLASSPATH, as it will conflict with that of the server. Check wi...more
Can I use JavaMail to backup my GMAIL account?
Short answer. Yes.
Longer answer:
In Gmail, access the SETTINGS link.
Select FORWARDING AND POP.
Select Enable POP for all mail (even mail that's already been downloaded). (POP Download step #1)...more