public static List<MailAccountData> ToAddressData(this AccountInfo account) { var fromEmailList = new List<MailAccountData>(); var mailBoxAccountSettings = SettingsManager.Instance.LoadSettingsFor<MailBoxAccountSettings>(SecurityContext.CurrentAccount.ID); var emailData = new MailAccountData { MailboxId = account.Id, Email = account.Email, Name = account.Name, Enabled = account.Enabled, OAuthConnection = account.OAuthConnection, AuthError = account.AuthError, QuotaError = account.QuotaError, Signature = account.Signature, EMailInFolder = account.EMailInFolder, IsAlias = false, IsGroup = false, IsTeamlabMailbox = account.IsTeamlabMailbox, IsDefault = mailBoxAccountSettings.DefaultEmail == account.Email, IsSharedDomainMailbox = account.IsSharedDomainMailbox }; fromEmailList.Add(emailData); foreach (var alias in account.Aliases) { emailData = new MailAccountData { MailboxId = account.Id, Email = alias.Email, Name = account.Name, Enabled = account.Enabled, OAuthConnection = false, AuthError = account.AuthError, QuotaError = account.QuotaError, Signature = account.Signature, EMailInFolder = account.EMailInFolder, IsAlias = true, IsGroup = false, IsTeamlabMailbox = account.IsTeamlabMailbox, IsDefault = mailBoxAccountSettings.DefaultEmail == alias.Email }; fromEmailList.Add(emailData); } foreach (var group in account.Groups) { if (fromEmailList.FindIndex(e => e.Email.Equals(group.Email)) != -1) continue; emailData = new MailAccountData { MailboxId = account.Id, Email = group.Email, Name = "", Enabled = true, OAuthConnection = false, AuthError = false, QuotaError = false, Signature = new SignatureDto(-1, account.Signature.Tenant, "", false), EMailInFolder = "", IsAlias = false, IsGroup = true, IsTeamlabMailbox = true }; fromEmailList.Add(emailData); } return fromEmailList; }
public static void GetNeededAccounts(this List<MailAccountData> accounts, out MailAccountData defaultAccount, out List<MailAccountData> commonAccounts, out List<MailAccountData> serverAccounts, out List<MailAccountData> aliases, out List<MailAccountData> groups) { defaultAccount = null; commonAccounts = new List<MailAccountData>(); serverAccounts = new List<MailAccountData>(); aliases = new List<MailAccountData>(); groups = new List<MailAccountData>(); if (accounts == null) { return; } for (int i = 0; i < accounts.Count; i++) { if (accounts[i].IsDefault) { defaultAccount = accounts[i]; } else if (accounts[i].IsGroup) { groups.Add(accounts[i]); } else if (accounts[i].IsAlias) { aliases.Add(accounts[i]); } else if (accounts[i].IsTeamlabMailbox) { serverAccounts.Add(accounts[i]); } else { commonAccounts.Add(accounts[i]); } } }