Alright here's what I found - my approach to this problem was all wrong so hopefully this posting will help someone in the future from making the same mistake. From extensive dumping and printfing from the 0.9.5 source I quickly discovered that I was trying to call a getMsgDatabase on the wrong subclass (the subclass of nsMsgDBFolder). I was expecting to be calling it on nsImapMailFolder but instead ended up calling it on nsLocalMailFolder. This made me back up completely and re-examine what I was doing. With my 20/20 hindsight now firmly in hand I can see how blatantly obvious it is to get at the message database.
1. get the Account Manager Service 2. get the Incoming Server for each of the accounts 3. get the RootFolder on the Incoming Server 4. get the subfolders of the RootFolder (this returns a nasty nsIEnumerator) 5. call getMsgDatabase on the subfolders 6. tada this avoids having to send in a msgWindow, you can safely send in null. From what I could see the msgWindow was passed around from function to function but was never actually used... I have one concern with this method right now though. In step 4 I got an nsIEnumerator back. From the nsIEnumerator.idl there is a comment as such: /* * DO NOT USE THIS INTERFACE. IT IS HORRIBLY BROKEN, USES NS_COMFALSE * AND IS BASICALLY IMPOSSIBLE TO USE CORRECTLY THROUGH PROXIES OR * XPCONNECT. IF YOU SEE NEW USES OF THIS INTERFACE IN CODE YOU ARE * REVIEWING, YOU SHOULD INSIST ON nsISimpleEnumerator. * * DON'T MAKE ME COME OVER THERE. */ Should this not be made into an nsISimpleEnumerator? Dan
