예제 #1
0
        public MailList[] GetLists(string domainName)
        {
            try
            {
                svcMailListAdmin svcLists = new svcMailListAdmin();
                PrepareProxy(svcLists);

                MailingListResult mResult = svcLists.GetMailingListsByDomain(
                    AdminUsername,
                    AdminPassword,
                    domainName
                );

                if (!mResult.Result)
                    throw new Exception(mResult.Message);

                List<MailList> mailLists = new List<MailList>();
                foreach (string listName in mResult.listNames)
                {
                    SettingsRequestResult sResult = svcLists.GetRequestedListSettings(
                        AdminUsername,
                        AdminPassword,
                        domainName,
                        listName,
                        smListSettings
                    );

                    if (!sResult.Result)
                        throw new Exception(sResult.Message);

                    SubscriberListResult rResult = svcLists.GetSubscriberList(
                        AdminUsername,
                        AdminPassword,
                        domainName,
                        listName
                    );

                    if (!rResult.Result)
                        throw new Exception(rResult.Message);

                    MailList list = new MailList();
                    list.Name = string.Concat(listName, "@", domainName);
                    SetMailListSettings(list, sResult.settingValues);
                    SetMailListMembers(list, rResult.Subscribers);
                    mailLists.Add(list);
                }

                return mailLists.ToArray();
            }
            catch (Exception ex)
            {
                throw new Exception("Couldn't obtain domain mail lists.", ex);
            }
        }
예제 #2
0
        public bool ListExists(string listName)
        {
            bool exists = false;

            try
            {
                string domain = GetDomainName(listName);
                string account = GetAccountName(listName);

                svcMailListAdmin lists = new svcMailListAdmin();
                PrepareProxy(lists);

                MailingListResult result = lists.GetMailingListsByDomain(AdminUsername, AdminPassword, domain);

                if (result.Result)
                {
                    foreach (string member in result.listNames)
                    {
                        if (string.Compare(member, listName, true) == 0)
                        {
                            exists = true;
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Couldn't obtain mail list.", ex);
            }

            return exists;
        }