NS_WITH_SERVICE( nsIMsgAccountManager, accMgr, kMsgAccountMgrCID, &rv);
nsCOMPtr <nsIMsgAccountManager> accMgr = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
PRBool nsImportGenericMail::FindAccount( nsIMsgFolder **ppFolder){	nsresult	rv;		*ppFolder = nsnull; 	NS_WITH_SERVICE( nsIMsgAccountManager, accMgr, kMsgAccountMgrCID, &rv);    if (NS_FAILED(rv)) {		IMPORT_LOG0( "*** Failed to create a account manager!\n");		return( PR_FALSE);	}		/*		First check the default account to see if it has a local mail		store.  If it does then use this account to import the mail.	*/	char *							pServerType = nsnull;	nsCOMPtr<nsIMsgAccount>			defAcc;	nsCOMPtr<nsIMsgIncomingServer>	localServer;	nsCOMPtr<nsIFolder>				rootFolder;	rv = accMgr->GetDefaultAccount( getter_AddRefs( defAcc));	if (NS_SUCCEEDED( rv) && (defAcc != nsnull)) {		rv = defAcc->GetIncomingServer( getter_AddRefs( localServer));		if (NS_SUCCEEDED( rv) && (localServer != nsnull)) {			rv = localServer->GetType( &pServerType);			if (NS_SUCCEEDED( rv) && pServerType &&				(!nsCRT::strcasecmp( pServerType, "none") ||				 !nsCRT::strcasecmp( pServerType, "POP3"))) {				nsCRT::free( pServerType);				rv = localServer->GetRootFolder( getter_AddRefs( rootFolder));				if (NS_SUCCEEDED( rv) && (rootFolder != nsnull)) {					rv = rootFolder->QueryInterface( NS_GET_IID(nsIMsgFolder), (void **)ppFolder);					if (NS_SUCCEEDED( rv))						return( PR_TRUE);				}			}			if (pServerType) {				nsCRT::free( pServerType);				pServerType = nsnull;			}		}	}		/*		Either an error occurred or the default account does not exist or		the default account is not of type "none" or "POP3".  Look for the		first account that we can use.	*/	nsCOMPtr<nsISupportsArray> accounts;	rv = accMgr->GetAccounts( getter_AddRefs( accounts));	if (NS_FAILED( rv)) {		IMPORT_LOG0( "*** Failed to get the accounts from the account manager\n");		return( PR_FALSE);	}		PRUint32	cnt = 0;	accounts->Count( &cnt);	nsISupports *	pSupports;	for (PRUint32 i = 0; i < cnt; i++) {		rv = accounts->GetElementAt( i, &pSupports);		if (NS_SUCCEEDED( rv) && pSupports) {			nsCOMPtr<nsISupports>		iFace( dont_AddRef( pSupports));			nsCOMPtr<nsIMsgAccount>		acc( do_QueryInterface( pSupports));			if (acc) {				nsCOMPtr<nsIMsgIncomingServer> server;				rv = acc->GetIncomingServer( getter_AddRefs( server));				if (NS_SUCCEEDED( rv) && (server != nsnull)) {					char *pType = nsnull;					rv = server->GetType( &pType);					if (pType) {						if (!nsCRT::strcasecmp( pType, "none") ||							!nsCRT::strcasecmp( pType, "POP3")) {							nsCRT::free( pType);							rv = server->GetRootFolder( getter_AddRefs( rootFolder));							if (NS_SUCCEEDED( rv) && (rootFolder != nsnull)) {   								rv = rootFolder->QueryInterface( NS_GET_IID(nsIMsgFolder), (void **) ppFolder);								if (NS_SUCCEEDED( rv))									return( PR_TRUE);							}						}						else {							nsCRT::free( pType);						}					}				}			}		}	}		return( PR_FALSE);		}