Ejemplo n.º 1
0
        private void cmdUnsubscribe_Click(object sender, System.EventArgs e)
        {
            string emailAddress = txtEmail.Text;

            if (emailAddress == null || emailAddress == string.Empty)
            {
                AddErrorMessage(Translate("/bvnetwork/sendmail/unsubscribe/errornoemail"));
                return;
            }

            emailAddress = emailAddress.Trim();
            EPiMailEngine engine      = new EPiMailEngine();
            ArrayList     resultArray = new ArrayList();

            EmailAddresses importedItems = new EmailAddresses();

            foreach (ListItem itm in this.chkNewsLetterLists.Items)
            {
                if (itm.Selected)
                {
                    //Load the selected recipient list
                    RecipientList list = RecipientList.Load(Convert.ToInt32(itm.Value));

                    SubscriptionStatus status = new SubscriptionStatus();
                    status.RecipientListName = list.Name;
                    //load user email address
                    EmailAddress emailItem = EmailAddress.Load(list.Id, emailAddress);
                    if (emailItem != null)
                    {
                        //Delete the user from the list, and show a confirm message
                        emailItem.Delete();
                        status.SubscriptionResult = true;
                        status.Message            = Translate("/bvnetwork/sendmail/unsubscribe/recipientremoved");
                    }
                    else
                    {
                        status.SubscriptionResult = false;
                        status.Message            = Translate("/bvnetwork/sendmail/unsubscribe/nosubscriptionfound");
                    }
                    //add the result to the array list.
                    resultArray.Add(status);
                }
            }
            // Done adding, now show the result
            rptResult.DataSource = resultArray;
            rptResult.DataBind();
        }