Solved

Java FetchProfile IMAP and UID in JavaMail

Posted on 2010-11-28
8
2,248 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
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

Database Solutions Engineer FAQs

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller single-server environments.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

628 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