Home Javamail List Information about folder



List Information about folder
Posted on: December 19, 2008 at 12:00 AM
This Example shows you how to show folder information. In this code we have used method of Folder class to retrieve information about folder where mail is stored.

List Information about folder

     

This Example shows you how to show folder information. In this code we have used method of Folder class to retrieve information about folder where mail is stored. Some of these methods are....

getName()is an abstract method and returns name of the folder of String type.
getFullName()returns the String type full name of folder
getURLName()returns the URL name representing this folder of URLName type.
getMessageCount()returns an integer value that represent total number of messages in this folder.
getNewMessageCount()returns an integer value that represent total number of new messages in this folder.
getUnreadMessageCount()returns an integer value that represent total number of unread messages in this folder.

FolderInfo.java


import java.util.*;
import javax.mail.*;

public class FolderInfo {

  public static void main(String args[]) throws Exception {

  Properties properties = System.getProperties();

  Session session = Session.getDefaultInstance(properties);
  Store store = session.getStore("pop3");

  store.connect("192.168.10.205", "test", "test");

  Folder folder = store.getFolder("inbox");
  folder.open(Folder.READ_ONLY);

  System.out.println("Name:  " + folder.getName());
  System.out.println("Full Name: " + folder.getFullName());
  System.out.println("URL: " + folder.getURLName());

  System.out.println("Has New Messages");
  System.out.println("Total Messages:  " + folder.getMessageCount());
  System.out.println("New Messages:  " + folder.getNewMessageCount());
  System.out.println("Unread Messages: " + folder.getUnreadMessageCount());
  }
} 

Output:

Name:  inbox
Full Name: inbox
URL: pop3://test@192.168.10.205/inbox
Has New Messages
Total Messages:  7
New Messages:  0
Unread Messages: 7

Download code

Related Tags for List Information about folder:
cclassormformiomailmethodsedformatfolderthisaishowforieexamplewheretoexamstoreinformationldwssheilusetrieinrminfoasmouttrclretrievemehowstoredtorxaxampsfoldatoldishainfmplcodcodessrithshoavstabatiinforminformatpleplodeonolo


More Tutorials from this section

Ask Questions?    Discuss: List Information about folder  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.