Solved

Java FetchProfile IMAP and UID in JavaMail

Posted on 2010-11-28
8
2,152 Views
Last Modified: 2013-11-19
Hi, I've seen tons of examples online of JavaMail using FetchProfile to get the UID of a message in POP3. The issue is I cannot use the same code (entirely) to get the UID in IMAP. (I understand the UIDs may be different as POP3 stores then as String, while IMAP as int).

So how can I get the UID of a message (with FetchProfile) when using IMAP?
0
Comment
Question by:amirsky
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 34225451
0
 

Author Comment

by:amirsky
ID: 34225487
I am aware of that code - it is what I am using. The question is, after fetching how do I then extract the UID form the message?

After doing:

FetchProfile fp = new FetchProfile();
fp.add(UIDFolder.FetchProfileItem.UID);
folder.fetch(msgs, fp);

If I am in POP3 i get then get each message's UID with:

folder.getUID(message);

BUT this method is not available with a Folder of type IMAP (IMAPFolder)
So the question is again, how do I get the UID in such a situation?
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 250 total points
ID: 34225581
>>BUT this method is not available with a Folder of type IMAP (IMAPFolder)

See http://java.sun.com/products/javamail/javadocs/com/sun/mail/imap/IMAPFolder.html#getUID(javax.mail.Message)
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 92

Assisted Solution

by:objects
objects earned 250 total points
ID: 34226910
use something like the following:

if (folder instanceof UIDFolder) {
   uid = ((UIDFolder)folder).getUID(message);
}
0
 

Author Comment

by:amirsky
ID: 34228079
The values for FetchProfile any part of am email's content? I basicallt see the same exmaple over and over again using only 3 values at best (UID, ENVELOPE, Subject).
0
 
LVL 92

Expert Comment

by:objects
ID: 34228108
Really depends on the backend as to what is supported, some may not let you prefetch anything.

0
 
LVL 92

Expert Comment

by:objects
ID: 34228114
purely from a javamail perspective see FetchProfile.Item and its subclasses

http://java.sun.com/products/javamail/javadocs/javax/mail/FetchProfile.Item.html

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 34229397
:)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question