Solved

Java FetchProfile IMAP and UID in JavaMail

Posted on 2010-11-28
8
2,220 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
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

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.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

734 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