Solved

Java FetchProfile IMAP and UID in JavaMail

Posted on 2010-11-28
8
2,036 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
  • 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now