In IMAP, what is defaultFolder?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Rizwan_Sattar
Posted On:   Monday, July 16, 2001 02:00 PM

Hello all, I wanted to check something with you. When you connect to an IMAP server and you invoke the command getDefaultFolder() on it, what folder does it return? I don't think it is inbox, because when I call defaultFolder.list(), it returns the folders that exist in that folder. If it were inbox, it would return no folders (and only incoming messages). I think I'm confused on the folder structure of IMAP. What I am trying to do is make some convenience methods for folder operations, such as - public void close(String folderName) and I am wondering if i should be using something like Folder FolderToClose = defaultFolder.getFolder(folderName); or Folder FolderT   More>>

Hello all,

I wanted to check something with you. When you connect to an IMAP server and you invoke the command getDefaultFolder() on it, what folder does it return? I don't think it is inbox, because when I call defaultFolder.list(), it returns the folders that exist in that folder. If it were inbox, it would return no folders (and only incoming messages).

I think I'm confused on the folder structure of IMAP. What I am trying to do is make some convenience methods for folder operations, such as -

			
public void close(String folderName)

and I am wondering if i should be using something like
			
Folder FolderToClose = defaultFolder.getFolder(folderName);

or

Folder FolderToClose = currentFolder.getParent().getFolder(foldername);

Thanks a lot, I appreciate any answers

Rizwan    <<Less

Re: In IMAP, what is defaultFolder?

Posted By:   Rizwan_Sattar  
Posted On:   Tuesday, July 17, 2001 10:22 AM

Hey all, I just wrote a small program to test what I asked. I should have done it before, but at least now if anyone else has this question, they can find the answer on this post ;)

// connect

Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore(provider);
store.connect(host, username, password);

// Open folders
Folder defaultFolder = store.getDefaultFolder();
Folder inbox = store.getFolder("INBOX");

System.out.println("defaultFolder is: "+defaultFolder.getName());
System.out.println("inbox folder is : "+inbox.getName());

System.out.println("Print folder list for defaultFolder");

Folder defaultfolderlist[] = defaultFolder.list();
for(int i=0; i System.out.println(defaultfolderlist[i].getName());
}

System.out.println("Print folder list for inbox");
Folder inboxlist[] = inbox.list();
for(int i=0; i System.out.println(inboxlist[i].getName());
}

store.close();


This produces the following output:

defaultFolder is:
inbox folder is : INBOX
Print folder list for defaultFolder
deleted_mail
sent
INBOX
Print folder list for inbox


Note that nothing is printed for the folderlist for inbox. I guess it is safe to assume that the "defaultFolder" is the unnamed, containing folder which is above all others.


-regards,

Rizwan

About | Sitemap | Contact