findEntry entry = { nsnull, PR_FALSE, nsnull };
if (NS_SUCCEEDED(rv)) { GetAccount(defaultKey, getter_AddRefs(m_defaultAccount)); } else { PRUint32 index; PRBool foundValidDefaultAccount = PR_FALSE; for (index = 0; index < count; index++) { nsCOMPtr<nsIMsgAccount> aAccount; rv = m_accounts->QueryElementAt(index, NS_GET_IID(nsIMsgAccount), (void **)getter_AddRefs(aAccount)); if (NS_SUCCEEDED(rv)) {  nsCOMPtr <nsIMsgIncomingServer> server; rv = aAccount->GetIncomingServer(getter_AddRefs(server)); NS_ENSURE_SUCCESS(rv,rv);  PRBool canBeDefaultServer = PR_FALSE; if (server) server->GetCanBeDefaultServer(&canBeDefaultServer);    if (canBeDefaultServer) { SetDefaultAccount(aAccount); foundValidDefaultAccount = PR_TRUE; break; } } } if (!foundValidDefaultAccount) {   nsCOMPtr<nsIMsgAccount> firstAccount; rv = m_accounts->QueryElementAt(0, NS_GET_IID(nsIMsgAccount), (void **)getter_AddRefs(firstAccount));
nsMsgAccountManager::GetDefaultAccount(nsIMsgAccount * *aDefaultAccount){  if (!aDefaultAccount) return NS_ERROR_NULL_POINTER;  if (!m_defaultAccount) {#if defined(DEBUG_alecf) || defined(DEBUG_sspitzer)    printf("No default account. Looking for one..\n");#endif        findEntry entry = { nsnull, PR_FALSE, nsnull };    m_accounts->Enumerate(hashTableFindFirst, (void *)&entry);    // are there ANY entries?    if (!entry.found) return NS_ERROR_UNEXPECTED;#if defined(DEBUG_alecf) || defined(DEBUG_sspitzer)    printf("Account (%p) found\n", entry.account);#endif    m_defaultAccount = entry.account;      }  *aDefaultAccount = m_defaultAccount;  NS_ADDREF(*aDefaultAccount);  return NS_OK;}