public virtual MailGroup GetGroup(string groupName) { try { svcAliasAdmin svcGroups = new svcAliasAdmin(); PrepareProxy(svcGroups); AliasInfoResult result = svcGroups.GetAlias(AdminUsername, AdminPassword, GetDomainName(groupName), groupName); if (!result.Result) throw new Exception(result.Message); MailGroup group = new MailGroup(); group.Name = groupName; group.Members = result.AliasInfo.Addresses; group.Enabled = true; // by default return group; } catch (Exception ex) { throw new Exception("Could not get mail domain group", ex); } }
public virtual bool GroupExists(string groupName) { try { svcAliasAdmin svcGroups = new svcAliasAdmin(); PrepareProxy(svcGroups); AliasInfoResult result = svcGroups.GetAlias(AdminUsername, AdminPassword, GetDomainName(groupName), groupName); return (result.Result && result.AliasInfo.Name != "Empty"); } catch (Exception ex) { throw new Exception("Could not check whether mail domain group exists", ex); } }
public bool MailAliasExists(string mailAliasName) { try { svcAliasAdmin aliases = new svcAliasAdmin(); PrepareProxy(aliases); AliasInfoResult result = aliases.GetAlias(AdminUsername, AdminPassword, GetDomainName(mailAliasName), mailAliasName); if ((result.AliasInfo.Name.Equals("Empty")) && (result.AliasInfo.Addresses.Length == 0)) return false; return true; } catch (Exception ex) { throw new Exception("Could not check whether mail alias exists", ex); } }
public MailAlias GetMailAlias(string mailAliasName) { svcAliasAdmin aliases = new svcAliasAdmin(); PrepareProxy(aliases); MailAlias alias = new MailAlias(); MailAlias newAlias = new MailAlias(); //convert old alliases created as mailboxes if (!MailAliasExists(mailAliasName)) { MailAccount account = GetAccount(mailAliasName); newAlias.Name = account.Name; newAlias.ForwardTo = account.ForwardingAddresses[0]; DeleteAccount(mailAliasName); CreateMailAlias(newAlias); return newAlias; } AliasInfoResult result = aliases.GetAlias(AdminUsername, AdminPassword, GetDomainName(mailAliasName), mailAliasName); alias.Name = result.AliasInfo.Name; alias.ForwardTo = result.AliasInfo.Addresses[0]; return alias; }
public MailAlias GetMailAlias(string mailAliasName) { svcAliasAdmin aliases = new svcAliasAdmin(); PrepareProxy(aliases); MailAlias alias = new MailAlias(); MailAlias newAlias = new MailAlias(); //convert old alliases created as mailboxes if (!MailAliasExists(mailAliasName)) { MailAccount account = GetAccount(mailAliasName); newAlias.Name = account.Name; if ((account.ForwardingAddresses != null) && (account.ForwardingAddresses.Length > 0)) { newAlias.ForwardTo = account.ForwardingAddresses[0]; } else { newAlias.ForwardTo = string.Empty; } DeleteAccount(mailAliasName); CreateMailAlias(newAlias); return newAlias; } AliasInfoResult result = aliases.GetAlias(AdminUsername, AdminPassword, GetDomainName(mailAliasName), mailAliasName); alias.Name = result.AliasInfo.Name; if ((result.AliasInfo.Addresses != null) && (result.AliasInfo.Addresses.Length > 0)) { alias.ForwardTo = result.AliasInfo.Addresses[0]; } else { alias.ForwardTo = "*****@*****.**"; } return alias; }