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); } } } }
public static void CreateFolderListFromTree(ref FolderCollection resultList, FolderCollection folderTree) { if (folderTree != null) { foreach (Folder f in folderTree) { resultList.Add(f); if (f.SubFolders.Count > 0) { CreateFolderListFromTree(ref resultList, f.SubFolders); } } } }
public static FolderCollection CreateDatabaseFolderTreeFromList(FolderCollection folderList) { FolderCollection result = new FolderCollection(); if (folderList != null) { foreach (Folder listFolder in folderList) { if (!AddDatabaseFolderNodeToTree(listFolder, result)) { result.Add(listFolder); } } } return(result); }
public static FolderCollection CreateImapFolderTreeFromList(MailBee.ImapMail.FolderCollection folderList, MailBee.ImapMail.FolderCollection subscribedFolderList) { FolderCollection result = new FolderCollection(); if (folderList != null) { int nestingLevel = 0; int addedCount = 0; while (folderList.Count > addedCount) { for (int i = 0; i < folderList.Count; i++) { MailBee.ImapMail.Folder fld = folderList[i]; if (fld.NestingLevel == nestingLevel) { bool hide = true; int subsCount = subscribedFolderList.Count; for (int j = 0; j < subsCount; j++) { if (fld.Name == subscribedFolderList[j].Name) { hide = false; subscribedFolderList.RemoveAt(j); subsCount--; break; } } if (nestingLevel == 0) { result.Add(new Folder(fld, hide)); } else { foreach (Folder resultFolder in result) { if (string.Compare(string.Format("{0}{1}{2}", resultFolder.ImapFolder.Name, resultFolder.ImapFolder.Delimiter, fld.ShortName), fld.Name, true, CultureInfo.InvariantCulture) == 0) { resultFolder.SubFolders.Add(new Folder(fld, hide)); break; } foreach (Folder resultFolder2 in resultFolder.SubFolders) { if (string.Compare(string.Format("{0}{1}{2}", resultFolder2.ImapFolder.Name, resultFolder2.ImapFolder.Delimiter, fld.ShortName), fld.Name, true, CultureInfo.InvariantCulture) == 0) { resultFolder2.SubFolders.Add(new Folder(fld, hide)); break; } foreach (Folder resultFolder3 in resultFolder2.SubFolders) { if (string.Compare(string.Format("{0}{1}{2}", resultFolder3.ImapFolder.Name, resultFolder3.ImapFolder.Delimiter, fld.ShortName), fld.Name, true, CultureInfo.InvariantCulture) == 0) { resultFolder3.SubFolders.Add(new Folder(fld, hide)); break; } foreach (Folder resultFolder4 in resultFolder3.SubFolders) { if (string.Compare(string.Format("{0}{1}{2}", resultFolder4.ImapFolder.Name, resultFolder4.ImapFolder.Delimiter, fld.ShortName), fld.Name, true, CultureInfo.InvariantCulture) == 0) { resultFolder4.SubFolders.Add(new Folder(fld, hide)); break; } } } } } } addedCount++; } } nestingLevel++; } } return(result); }