Ejemplo n.º 1
0
        /// <summary>
        /// Deletes specified mail list.
        /// </summary>
        /// <param name="listName">Mail list name.</param>
        public virtual void DeleteList(string listName)
        {
            try
            {
                WebsitePanelMailListAdmin svcLists = new WebsitePanelMailListAdmin();
                PrepareProxy(svcLists);

                GenericResult result = svcLists.DeleteMailingList(AdminUsername, AdminPassword, listName);

                if (!result.Result)
                    throw new Exception(result.Message);
            }
            catch (Exception ex)
            {
                throw new Exception("Could not delete mail list", ex);
            }
        }
Ejemplo n.º 2
0
        public virtual void UpdateList(MailList list)
        {
            try
            {
                WebsitePanelMailListAdmin svcLists = new WebsitePanelMailListAdmin();
                PrepareProxy(svcLists);

                MailListPostOptions postMode = MailListPostOptions.Anyone;
                if (list.PostingMode == PostingMode.MembersCanPost)
                    postMode = MailListPostOptions.SubscribersOnly;
                if (list.PostingMode == PostingMode.ModeratorCanPost)
                    postMode = MailListPostOptions.ModeratorOnly;

                GenericResult result = svcLists.UpdateMailingList(AdminUsername, AdminPassword,
                    list.Name,
                    list.ModeratorAddress,
                    list.Description,
                    list.MaxMessageSize,
                    list.MaxRecipientsPerMessage,
                    list.EnableSubjectPrefix,
                    list.SubjectPrefix,
                    list.Members,
                    postMode,
                    (list.ReplyToMode == ReplyTo.RepliesToList),
                    list.Password,
                    list.RequirePassword);

                if (!result.Result)
                    throw new Exception(result.Message);
            }
            catch (Exception ex)
            {
                throw new Exception("Could not update mail list", ex);
            }
        }
Ejemplo n.º 3
0
        public virtual MailList[] GetLists(string domainName)
        {
            try
            {
                WebsitePanelMailListAdmin svcLists = new WebsitePanelMailListAdmin();
                PrepareProxy(svcLists);

                MailingListsResult result = svcLists.GetMailingLists(AdminUsername, AdminPassword, domainName);

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

                List<MailList> items = new List<MailList>();
                foreach (MailingListInfo listInfo in result.MailingLists)
                {
                    MailList item = new MailList();
                    item.Name = listInfo.Name;
                    item.Description = listInfo.Description;
                }

                return items.ToArray();
            }
            catch (Exception ex)
            {
                throw new Exception("Could not get mail list", ex);
            }
        }
Ejemplo n.º 4
0
        public virtual MailList GetList(string listName)
        {
            try
            {
                WebsitePanelMailListAdmin svcLists = new WebsitePanelMailListAdmin();
                PrepareProxy(svcLists);

                MailingListResult result = svcLists.GetMailingList(AdminUsername, AdminPassword, listName);

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

                MailList item = new MailList();
                item.Description = result.MailingList.Description;
                item.EnableSubjectPrefix = result.MailingList.EnableSubjectPrefix;
                item.SubjectPrefix = result.MailingList.SubjectPrefix;
                item.Enabled = true;
                item.MaxMessageSize = result.MailingList.MaxMessageSize;
                item.MaxRecipientsPerMessage = result.MailingList.MaxRecipientsPerMessage;
                item.Members = result.MailingList.Members ?? new string[] { };
                item.Moderated = !String.IsNullOrEmpty(result.MailingList.ModeratorAddress);
                item.ModeratorAddress = result.MailingList.ModeratorAddress;
                item.Name = result.MailingList.Name;
                item.Password = result.MailingList.Password;
                item.RequirePassword = result.MailingList.RequirePassword;

                // post mode
                PostingMode postMode = PostingMode.AnyoneCanPost;
                if (result.MailingList.PostingMode == MailListPostOptions.ModeratorOnly)
                    postMode = PostingMode.ModeratorCanPost;
                else if (result.MailingList.PostingMode == MailListPostOptions.SubscribersOnly)
                    postMode = PostingMode.MembersCanPost;
                item.PostingMode = postMode;
                item.ReplyToMode = result.MailingList.ReplyToList ? ReplyTo.RepliesToList : ReplyTo.RepliesToSender;

                return item;
            }
            catch (Exception ex)
            {
                throw new Exception("Could not get mail list", ex);
            }
        }
Ejemplo n.º 5
0
        public virtual bool ListExists(string listName)
        {
            try
            {
                WebsitePanelMailListAdmin svcLists = new WebsitePanelMailListAdmin();
                PrepareProxy(svcLists);

                GenericResult result = svcLists.MailingListExists(AdminUsername, AdminPassword, listName);

                return result.Result;
            }
            catch (Exception ex)
            {
                throw new Exception("Could not check whether mailing list exists", ex);
            }
        }