protected void AutoCheckMailForAccount(Account acct)
        {
            if (acct != null)
            {
                try
                {
                    DbStorage              dbs     = DbStorageCreator.CreateDatabaseStorage(acct);
                    MailProcessor          mp      = new MailProcessor(dbs);
                    WebmailResourceManager _resMan = (new WebmailResourceManagerCreator()).CreateResourceManager();
                    try
                    {
                        mp.MessageDownloaded += new DownloadedMessageHandler(mp_MessageDownloaded);
                        mp.Connect();

                        FolderCollection fc1 = dbs.GetFolders();
                        FolderCollection fc2 = new FolderCollection();
                        foreach (Folder fld in fc1)
                        {
                            if (fld.Type == FolderType.Inbox)
                            {
                                fc2.Add(fld);
                            }
                        }
                        Dictionary <long, string> updatedFolders = mp.Synchronize(fc2);
                        string strFolders = "";
                        foreach (KeyValuePair <long, string> kvp in updatedFolders)
                        {
                            strFolders += "{id: " + kvp.Key.ToString() + ", fullName: '" + kvp.Value + "'}, ";
                        }
                        Response.Write(@"<script type=""text/javascript"">parent.SetUpdatedFolders([" + strFolders.TrimEnd(new char[2] {
                            ',', ' '
                        }) + "], false);</script>");
                    }
                    finally
                    {
                        mp.MessageDownloaded -= new DownloadedMessageHandler(mp_MessageDownloaded);
                        mp.Disconnect();
                    }
                }
                catch (WebMailException ex)
                {
                    Log.WriteException(ex);
                    errorDesc = Utils.EncodeJsSaveString(ex.Message);
                    if (Type == 1 || Type == 2)
                    {
                        Session.Add(Constants.sessionErrorText, errorDesc);
                    }
                }
            }
        }
 protected void CheckMailForAccount(Account acct)
 {
     if (acct != null)
     {
         try
         {
             DbStorage              dbs     = DbStorageCreator.CreateDatabaseStorage(acct);
             MailProcessor          mp      = new MailProcessor(dbs);
             WebmailResourceManager _resMan = (new WebmailResourceManagerCreator()).CreateResourceManager();
             try
             {
                 mp.MessageDownloaded += new DownloadedMessageHandler(mp_MessageDownloaded);
                 Response.Write(@"<script type=""text/javascript"">parent.SetStateTextHandler(""" + _resMan.GetString("LoggingToServer") + @""");</script>");
                 mp.Connect();
                 Response.Write(@"<script type=""text/javascript"">parent.SetStateTextHandler(""" + _resMan.GetString("GettingMsgsNum") + @""");</script>");
                 Dictionary <long, string> updatedFolders = mp.Synchronize(dbs.GetFolders());
                 if (Type == 0)
                 {
                     string strFolders = "";
                     foreach (KeyValuePair <long, string> kvp in updatedFolders)
                     {
                         strFolders += "{id: " + kvp.Key.ToString() + ", fullName: '" + kvp.Value + "'}, ";
                     }
                     Response.Write(@"<script type=""text/javascript"">parent.SetUpdatedFolders([" + strFolders.TrimEnd(new char[2] {
                         ',', ' '
                     }) + "]);</script>");
                 }
             }
             finally
             {
                 mp.MessageDownloaded -= new DownloadedMessageHandler(mp_MessageDownloaded);
                 Response.Write(@"<script type=""text/javascript"">parent.SetStateTextHandler(""" + _resMan.GetString("LoggingOffFromServer") + @""");</script>");
                 mp.Disconnect();
             }
         }
         catch (WebMailException ex)
         {
             Log.WriteException(ex);
             errorDesc = Utils.EncodeJsSaveString(ex.Message);
             if (Type == 1)
             {
                 Session.Add(Constants.sessionErrorText, errorDesc);
             }
         }
     }
 }