nsCOMPtr<nsIWindowMediator> mediator ( do_GetService(NS_WINDOWMEDIATOR_CONTRACTID) ); if (mediator) { nsCOMPtr<nsIDOMWindowInternal> domWindow; nsAutoString mailName; mailName.AssignWithConversion(mailWinName());  mediator->GetMostRecentWindow( mailName.get(), getter_AddRefs(domWindow)); if (domWindow) activateWindow(domWindow); else {  nsCOMPtr <nsIMessengerWindowService> messengerWindowService = do_GetService(NS_MESSENGERWINDOWSERVICE_CONTRACTID);   if (messengerWindowService) messengerWindowService->OpenMessengerWindowWithUri("mail:3pane", nsnull); } }
nsAutoString mailName; mailName.AssignWithConversion(mailWinName()); openMailWindow(mailName.get(), nsnull);
    static long CALLBACK WindowProc( HWND msgWindow, UINT msg, WPARAM wp, LPARAM lp )     {      if ( msg == WM_USER )       {         if ( lp == WM_LBUTTONDBLCLK )          {           nsCOMPtr<nsIWindowMediator> mediator ( do_GetService(NS_WINDOWMEDIATOR_CONTRACTID) );           if (mediator)           {             nsCOMPtr<nsIDOMWindowInternal> domWindow;             nsAutoString mailName;             mailName.AssignWithConversion(mailWinName());             mediator->GetMostRecentWindow( mailName.get(), getter_AddRefs(domWindow));             if (domWindow)               activateWindow(domWindow);             else             {               // the user doesn't have a mail window open already so open one for them...                nsCOMPtr <nsIMessengerWindowService> messengerWindowService = do_GetService(NS_MESSENGERWINDOWSERVICE_CONTRACTID);                // if we want to preselect the first account with new mail, here is where we would try to generate                // a uri to pass in (and add code to the messenger window service to make that work)                if (messengerWindowService)                   messengerWindowService->OpenMessengerWindowWithUri("mail:3pane", nsnull);             }           }         }      }           return TRUE;    }