private void copyAccounts(Server destserver, bool dropDest) { MailAccountCollection sourceaccounts = sourceserver.Mail.Accounts; MailAccountCollection destaccounts = destserver.Mail.Accounts; SqlMail sm; sm = destserver.Mail; try { foreach (MailAccount account in sourceaccounts) { string accountname = account.Name; ItemToCopy item = itemsToCopy.Find(x => x.Name == accountname); if (item.IsChecked) { if (destaccounts.Contains(accountname)) { if (!dropDest) { showOutput.displayOutput(string.Format("Account {0} already exists on destination. Skipping", accountname)); continue; } destaccounts[accountname].Drop(); destaccounts.Refresh(); } MailAccount newAccount = default(MailAccount); newAccount = new MailAccount(sm, account.Name, account.Description, account.DisplayName, account.EmailAddress); newAccount.ReplyToAddress = account.ReplyToAddress; newAccount.Create(); newAccount.MailServers[0].Rename(account.MailServers[0].Name); newAccount.Alter(); showOutput.displayOutput(string.Format("Copied mail account {0}", accountname)); } } } catch (Exception ex) { showOutput.displayOutput("Failed to copy account"); showOutput.displayOutput(ex.Message, true); } }