Example #1
0
 private static void FillFromDataTable(DataTable table, EmailAddresses emailAddresses)
 {
     foreach (DataRow row in table.Rows)
     {
         EmailAddress emailAddress = new EmailAddress(row);
         emailAddresses.Add(emailAddress);
     }
 }
Example #2
0
 private static void FillFromDataTable(DataTable table, EmailAddresses emailAddresses)
 {
     foreach (DataRow row in table.Rows)
     {
         EmailAddress emailAddress = new EmailAddress(row);
         emailAddresses.Add(emailAddress);
     }
 }
Example #3
0
        public static EmailAddresses ListAll(int recipientListId)
        {
            EmailAddresses items = new EmailAddresses();

            RecipientData dataUtil = GetWorker();
            DataTable emailAddressTable = dataUtil.RecipientListGetAllItems(recipientListId);
            FillFromDataTable(emailAddressTable, items);
            return items;
        }
Example #4
0
        /// <summary>
        /// Imports email addresses into a Recipient List
        /// </summary>
        /// <param name="emailArray">The email addresses to import.</param>
        /// <param name="invalidEmailAddresses">A list of all available email addresses that could not be parsed as a valid address</param>
        /// <returns>The number of email addresses imported as new work items. Duplicates are not part of this number.</returns>
        public int ImportEmailAddresses(string[] emailArray, out List <string> invalidEmailAddresses, out List <string> duplicateAddresses)
        {
            EmailAddresses importedItems = new EmailAddresses();

            invalidEmailAddresses = new List <string>();
            duplicateAddresses    = new List <string>();

            int numberOfNewItems = 0;

            foreach (string emailAddress in emailArray)
            {
                // TODO: This can be optimized by checking the
                // existance of these email addresses in batches

                // Clean address (this is done on save, so we need to make sure it's correct)
                string emailAddressCleaned = NewsLetterUtil.CleanEmailAddress(emailAddress);

                // Validate email address
                if (EmailSyntaxValidator.Validate(emailAddressCleaned) == false)
                {
                    // Invalid email address, skip it.
                    invalidEmailAddresses.Add(emailAddressCleaned);
                }
                else
                {
                    // Check if already imported. This is the quickest duplicate check
                    EmailAddress emailItem = importedItems.Find(emailAddressCleaned);
                    if (emailItem == null)
                    {
                        // Handle duplicates - try to load it first
                        emailItem = EmailAddress.Load(Id, emailAddressCleaned);
                        if (emailItem == null)
                        {
                            // Create it, and save it. It is automatically
                            // added to the WorkItems collection
                            emailItem = this.CreateEmailAddress(emailAddressCleaned);
                            // Save
                            emailItem.Save();
                            numberOfNewItems++;
                        }
                        else
                        {
                            // Duplicate
                            duplicateAddresses.Add(emailAddressCleaned);
                        }

                        // Add to imported collection, for quick
                        // in memory duplicate check
                        importedItems.Add(emailItem);
                    }
                }
            }

            ClearEmailAddressCount();

            return(numberOfNewItems);
        }
Example #5
0
        public static EmailAddresses ListAll(int recipientListId)
        {
            EmailAddresses items = new EmailAddresses();

            RecipientData dataUtil          = GetWorker();
            DataTable     emailAddressTable = dataUtil.RecipientListGetAllItems(recipientListId);

            FillFromDataTable(emailAddressTable, items);
            return(items);
        }
Example #6
0
 internal static void FillFromDataTable(DataTable table, EmailAddresses items)
 {
     foreach (DataRow row in table.Rows)
     {
         //RecipientList recipientList = new RecipientList(row);
         //recList.CreateEmailAddress(row["EmailAddress"].ToString());
         EmailAddress email = new EmailAddress(row);
         items.Add(email);
     }
 }
Example #7
0
        /// <summary>
        /// Deletes the email address items for this recipient list
        /// </summary>
        /// <remarks>
        /// The EmailAddress property will be cleared when calling this method.
        /// </remarks>
        public void DeleteEmailAddressItems()
        {
            RecipientData dataUtil = GetWorker();

            dataUtil.RecipientListRemoveAllItems(_id);

            // Reset collection
            _emailAddresses = null;
            ClearEmailAddressCount();
        }
Example #8
0
        private void cmdSubscribe_Click(object sender, System.EventArgs e)
        {
            string emailAddress = txtEmail.Text;

            if (emailAddress == null || emailAddress == string.Empty)
            {
                AddErrorMessage(Translate("/bvnetwork/sendmail/subscribe/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)
                {
                    // Check that the user does not belong to the groups
                    // already.
                    RecipientList list = RecipientList.Load(Convert.ToInt32(itm.Value));

                    SubscriptionStatus status = new SubscriptionStatus();
                    status.RecipientListName = list.Name;

                    //Load and check if the email typed by the user exists.
                    EmailAddress emailItem = EmailAddress.Load(list.Id, emailAddress);
                    if (emailItem == null)
                    {
                        // Create it, and save it. It is automatically
                        // added to the WorkItems collection
                        emailItem = list.CreateEmailAddress(emailAddress);
                        // Save
                        emailItem.Save();
                        status.SubscriptionResult = true;
                    }
                    else
                    {
                        // Already subscribes
                         status.SubscriptionResult = true;
                         status.Message = Translate("/bvnetwork/sendmail/subscribe/alreadysubscribe") ;
                    }

                    resultArray.Add(status);
                }

            }

            // Done adding, now show the result
            rptResult.DataSource = resultArray;
            rptResult.DataBind();
        }
Example #9
0
        /// <summary>
        /// Searches the recipientList for emailaddresses that matches
        /// a specified string. Will search all emails with a LIKE clause.
        /// </summary>
        /// <param name="recipientListId">The recipient list id.</param>
        /// <param name="searchFor">The email to search for.</param>
        /// <returns>A collection of recipient. The collection count can be 0</returns>
        public static EmailAddresses Search(int recipientListId, string searchFor)
        {
            //RecipientList items = new RecipientList();
            EmailAddresses items    = new EmailAddresses();
            RecipientData  dataUtil = GetWorker();

            DataTable recipientsTable = dataUtil.RecipientListSearch(recipientListId, searchFor);

            FillFromDataTable(recipientsTable, items);
            return(items);
        }
Example #10
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();
        }
Example #11
0
 internal static void FillFromDataTable(DataTable table, EmailAddresses items)
 {
     foreach (DataRow row in table.Rows)
     {
         //RecipientList recipientList = new RecipientList(row);
         //recList.CreateEmailAddress(row["EmailAddress"].ToString());
         EmailAddress email = new EmailAddress(row);
         items.Add(email);
     }
 }
Example #12
0
        /// <summary>
        /// Imports email addresses into a Recipient List
        /// </summary>
        /// <param name="emailArray">The email addresses to import.</param>
        /// <param name="invalidEmailAddresses">A list of all available email addresses that could not be parsed as a valid address</param>
        /// <returns>The number of email addresses imported as new work items. Duplicates are not part of this number.</returns>
        public int ImportEmailAddresses(string[] emailArray, out List<string> invalidEmailAddresses, out List<string> duplicateAddresses)
        {
            EmailAddresses importedItems = new EmailAddresses();
            invalidEmailAddresses = new List<string>();
            duplicateAddresses = new List<string>();

            int numberOfNewItems = 0;
            foreach (string emailAddress in emailArray)
            {
                // TODO: This can be optimized by checking the
                // existance of these email addresses in batches

                // Clean address (this is done on save, so we need to make sure it's correct)
                string emailAddressCleaned = NewsLetterUtil.CleanEmailAddress(emailAddress);

                // Validate email address
                if (EmailSyntaxValidator.Validate(emailAddressCleaned) == false)
                {
                    // Invalid email address, skip it.
                    invalidEmailAddresses.Add(emailAddressCleaned);
                }
                else
                {
                    // Check if already imported. This is the quickest duplicate check
                    EmailAddress emailItem = importedItems.Find(emailAddressCleaned);
                    if (emailItem == null)
                    {
                        // Handle duplicates - try to load it first
                        emailItem = EmailAddress.Load(Id, emailAddressCleaned);
                        if (emailItem == null)
                        {

                            // Create it, and save it. It is automatically
                            // added to the WorkItems collection
                            emailItem = this.CreateEmailAddress(emailAddressCleaned);
                            // Save
                            emailItem.Save();
                            numberOfNewItems++;
                        }
                        else
                        {
                            // Duplicate
                            duplicateAddresses.Add(emailAddressCleaned);
                        }

                        // Add to imported collection, for quick
                        // in memory duplicate check
                        importedItems.Add(emailItem);
                    }
                }
            }

            ClearEmailAddressCount();

            return numberOfNewItems;
        }
Example #13
0
        /// <summary>
        /// Deletes the email address items for this recipient list
        /// </summary>
        /// <remarks>
        /// The EmailAddress property will be cleared when calling this method.
        /// </remarks>
        public void DeleteEmailAddressItems()
        {
            RecipientData dataUtil = GetWorker();
            dataUtil.RecipientListRemoveAllItems(_id);

            // Reset collection
            _emailAddresses = null;
            ClearEmailAddressCount();
        }
Example #14
0
        /// <summary>
        /// Searches the recipientList for emailaddresses that matches
        /// a specified string. Will search all emails with a LIKE clause.
        /// </summary>
        /// <param name="recipientListId">The recipient list id.</param>
        /// <param name="searchFor">The email to search for.</param>
        /// <returns>A collection of recipient. The collection count can be 0</returns>
        public static EmailAddresses Search(int recipientListId, string searchFor)
        {
            //RecipientList items = new RecipientList();
            EmailAddresses items = new EmailAddresses();
            RecipientData dataUtil = GetWorker();

            DataTable recipientsTable = dataUtil.RecipientListSearch(recipientListId, searchFor);
            FillFromDataTable(recipientsTable, items);
            return items;
        }
 public void BindWorkItemData(EmailAddresses items)
 {
     grdItems.DataSource = items;
     grdItems.DataBind();
 }