Ejemplo n.º 1
0
        public EmailAddressCollection ParseTo(string text)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }
            EmailAddressCollection addresss = new EmailAddressCollection();
            Match match = regTo.Match(text);

            if (match.Success && (match.Groups.Count > 0))
            {
                foreach (Match match2 in regAddressAll.Matches(match.Groups[0].Value))
                {
                    EmailAddress address = this.ParseEmail(match2.Groups[1].Value);
                    if (address != null)
                    {
                        addresss.Add(address);
                    }
                }
                return(addresss);
            }
            foreach (Match match3 in regAddressAll.Matches(text))
            {
                EmailAddress address2 = this.ParseEmail(match3.Groups[1].Value);
                if (address2 != null)
                {
                    addresss.Add(address2);
                }
            }
            return(addresss);
        }
Ejemplo n.º 2
0
 private void AddAdressesToCollection(
     EmailAddressCollection adresses,
     string firstAdress = null)
 {
     adresses.Add(firstAdress ?? this.RndRecipMail());
     if (RndTrueFalse() && this.recipientsMax > 1)
     {
         adresses.Add(this.RndRecipMail());
     }
 }
        public static EmailAddressCollection GetCollection(int instructorId)
        {
            EmailAddressCollection tempList = null;

            using (SqlConnection myConnection = new SqlConnection(AppConfiguration.ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("usp_GetEmail", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

                    myCommand.Parameters.AddWithValue("@QueryId", SelectTypeEnum.GetCollectionByInstructor);
                    myCommand.Parameters.AddWithValue("@InstructorId", instructorId);

                    myConnection.Open();

                    using (SqlDataReader myReader = myCommand.ExecuteReader())
                    {
                        if (myReader.HasRows)
                        {
                            tempList = new EmailAddressCollection();
                            while (myReader.Read())
                            {
                                tempList.Add(FillDataRecord(myReader));
                            }
                        }
                        myReader.Close();
                    }
                }
            }
            return(tempList);
        }
Ejemplo n.º 4
0
 private void SetRecipient(EmailAddressCollection emailAddressCollection, GXMailRecipientCollection gXMailRecipientCollection)
 {
     foreach (GXMailRecipient to in gXMailRecipientCollection)
     {
         emailAddressCollection.Add(new EmailAddress(to.Name, to.Address));
     }
 }
        /// <summary Get Collection>
        /// Get collection of emails. If no records to return, EmailCollection will be null.
        /// </summary>
        /// <returns></returns>
        public static EmailAddressCollection GetCollection(int employeeId)
        {
            EmailAddressCollection tempList = null;

            using (SqlConnection myConnection = new SqlConnection(AppConfiguration.ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("usp_GetEmail", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

                    myCommand.Parameters.AddWithValue("@QueryId", SelectTypeEnum.GetCollectionById);
                    myCommand.Parameters.AddWithValue("@EmployeeId", employeeId);

                    myConnection.Open();

                    using (SqlDataReader myReader = myCommand.ExecuteReader())
                    {
                        if (myReader.HasRows)
                        {
                            tempList = new EmailAddressCollection();

                            while (myReader.Read())
                            {
                                tempList.Add(FillDataRecord(myReader));
                            }
                        }
                        myReader.Close();
                    }
                }
            }
            return tempList;
        }
Ejemplo n.º 6
0
        public void Add_EmailAddressUnknownToEmptyCollection_DoesNotExtendTheCollection()
        {
            var exp = new EmailAddressCollection();
            var act = new EmailAddressCollection();
            act.Add(EmailAddress.Unknown);

            CollectionAssert.AreEqual(exp, act);
        }
Ejemplo n.º 7
0
        public void Add_EmailAddressUnknownToEmptyCollection_DoesNotExtendTheCollection()
        {
            var exp = new EmailAddressCollection();
            var act = new EmailAddressCollection();

            act.Add(EmailAddress.Unknown);

            CollectionAssert.AreEqual(exp, act);
        }
Ejemplo n.º 8
0
        protected EmailAddressCollection GetEmailAddressCollection(IEnumerable <string> emailAddresses)
        {
            var emailAddressCollection = new EmailAddressCollection();

            foreach (var emailAddress in emailAddresses)
            {
                emailAddressCollection.Add(emailAddress);
            }
            return(emailAddressCollection);
        }
        public void OverloadOfAddAddsItemToCollection()
        {
            var          emailAddressCollection = new EmailAddressCollection();
            const string addressText            = "*****@*****.**";

            emailAddressCollection.Add(addressText, ContactType.Business);

            Assert.Single(emailAddressCollection);
            Assert.Equal(ContactType.Business, emailAddressCollection[0].ContactType);
            Assert.Equal(addressText, emailAddressCollection[0].EmailAddressText);
        }
Ejemplo n.º 10
0
 public void InsertAndRemove()
 {
     Assert.DoesNotThrow(delegate
     {
         EmailAddress emailAddress = new EmailAddress();
         EmailAddressCollection emailCollection = new EmailAddressCollection();
         emailCollection.Add(emailAddress);
         emailCollection[0] = emailAddress;
         emailAddress       = emailCollection[0];
         emailCollection.Remove(emailAddress);
     });
 }
Ejemplo n.º 11
0
        public virtual SendResult SendOne(string addressFrom, IEnumerable <string> addressTo, string messageSubject, string messageText)
        {
            EmailAddress           from = new EmailAddress(addressFrom);
            EmailAddressCollection to   = new EmailAddressCollection();

            foreach (string str in addressTo)
            {
                to.Add(new EmailAddress(str));
            }
            SmtpMessage message = new SmtpMessage(from, to, messageSubject, messageText);

            return(this.SendOne(message));
        }
Ejemplo n.º 12
0
    /// <summary>
    /// Convert the SMS recipient list from MobilePhone collection type to EmailAddressCollection type.
    /// </summary>
    /// <param name="recipientCollection">Recipient list in a MobilePhone collection type.</param>
    /// <returns>An EmailAddressCollection object containing recipients with "MOBILE" address type. </returns>
    /* private */ static EmailAddressCollection ConvertSMSRecipientsFromMobilePhoneCollectionToEmailAddressCollection(Collection <MobilePhone> recipientCollection)
    {
        EmailAddressCollection emailCollection = new EmailAddressCollection(XmlElementNames.Address);

        for (MobilePhone recipient in recipientCollection)
        {
            EmailAddress emailAddress = new EmailAddress(
                recipient.Name,
                recipient.PhoneNumber,
                RuleActions.MobileType);
            emailCollection.Add(emailAddress);
        }

        return(emailCollection);
    }
Ejemplo n.º 13
0
        public void Equals_ChecksForEmailEquality( )
        {
            var addresses1 = new EmailAddressCollection {
                new EmailAddress("*****@*****.**")
            };

            var addresses2 = new EmailAddressCollection {
                new EmailAddress("*****@*****.**")
            };

            Assert.AreEqual(addresses1, addresses2);

            addresses2.Add(new EmailAddress("*****@*****.**"));
            Assert.AreNotEqual(addresses1, addresses2);
        }
Ejemplo n.º 14
0
        private string ResolveRecipients(string[] unresolvedRecipients, EmailAddressCollection emailAddressCollection)
        {
            string resolvedRecipients = string.Empty;

            foreach (string recipient in unresolvedRecipients)
            {
                try
                {
                    NameResolutionCollection nameResolutionCollection = exchangeService.ResolveName(recipient);
                    if (nameResolutionCollection != null)
                    {
                        if (nameResolutionCollection.Count == 1)
                        {
                            if (nameResolutionCollection[0].Mailbox != null)
                            {
                                emailAddressCollection.Add(nameResolutionCollection[0].Mailbox.Address);
                            }
                            resolvedRecipients += nameResolutionCollection[0].Mailbox.Address + "; ";
                        }
                        else
                        {
                            if (errorRecipients.Contains(recipient))
                            {
                                errorRecipients.Add(recipient);
                            }
                        }
                    }
                }
                catch
                {
                    if (errorRecipients.Contains(recipient))
                    {
                        errorRecipients.Add(recipient);
                    }
                }
            }
            return(resolvedRecipients);
        }
Ejemplo n.º 15
0
        private static EmailAddressCollection GetAddressesFromTable(DataTable addressTable, string className)
        {
            EmailAddressCollection addresses = new EmailAddressCollection();

            DataView view = GetAddressViewByClassName(addressTable, className);

            foreach (DataRowView drv in view)
            {
                EmailAddress address = new EmailAddress();

                ORMapping.DataRowToObject(drv.Row, address);

                addresses.Add(address);
            }

            return addresses;
        }
Ejemplo n.º 16
0
 private void AddAdressesToCollection(
     EmailAddressCollection adresses,
     string firstAdress = null)
 {
     adresses.Add(firstAdress ?? this.RndRecipMail());
     if (RndTrueFalse() && this.recipientsMax > 1)
     {
         adresses.Add(this.RndRecipMail());
     }
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Gets the email address from the details array
        /// </summary>
        /// <returns>A <see cref="EmailAddressCollection"/></returns>
        private static EmailAddressCollection ParseEmailAddresses()
        {
            EmailAddressCollection emailAddressCollection = new EmailAddressCollection();

            var emailStrings = _contactDetails.Where(s => s.StartsWith("EMAIL"));

            foreach (string email in emailStrings)
            {
                try
                {
                    string emailString = email.Replace("EMAIL;", "").Replace("EMAIL:", "");
                    //Remove multiple typing
                    if (emailString.Contains(";"))
                    {
                        emailString = emailString.Replace(";", "");
                    }

                    //Logic
                    if (emailString.StartsWith("INTERNET:"))
                    {
                        emailString = emailString.Replace("INTERNET:", "");
                        EmailAddress emailAddress = new EmailAddress
                        {
                            Email = new MailAddress(emailString),
                            Type  = EmailType.Internet
                        };
                        emailAddressCollection.Add(emailAddress);
                    }
                    else if (emailString.StartsWith("HOME:"))
                    {
                        emailString = emailString.Replace("HOME:", "");
                        EmailAddress emailAddress = new EmailAddress
                        {
                            Email = new MailAddress(emailString),
                            Type  = EmailType.Home
                        };
                        emailAddressCollection.Add(emailAddress);
                    }
                    else if (emailString.StartsWith("WORK:"))
                    {
                        emailString = emailString.Replace("WORK:", "");
                        EmailAddress emailAddress = new EmailAddress
                        {
                            Email = new MailAddress(emailString),
                            Type  = EmailType.Work
                        };
                        emailAddressCollection.Add(emailAddress);
                    }
                    else if (emailString.StartsWith("AOL:") || emailString.StartsWith("aol:"))
                    {
                        emailString = emailString.Replace("AOL:", "").Replace("aol:", "");
                        EmailAddress emailAddress = new EmailAddress
                        {
                            Email = new MailAddress(emailString),
                            Type  = EmailType.AOL
                        };
                        emailAddressCollection.Add(emailAddress);
                    }
                    else if (emailString.StartsWith("APPLELINK:") || emailString.StartsWith("applelink:"))
                    {
                        emailString = emailString.Replace("APPLELINK:", "").Replace("applelink:", "");
                        EmailAddress emailAddress = new EmailAddress
                        {
                            Email = new MailAddress(emailString),
                            Type  = EmailType.Applelink
                        };
                        emailAddressCollection.Add(emailAddress);
                    }
                    else if (emailString.StartsWith("IBMMAIL:") || emailString.StartsWith("ibmmail:"))
                    {
                        emailString = emailString.Replace("IBMMAIL:", "").Replace("ibmmail:", "");
                        EmailAddress emailAddress = new EmailAddress
                        {
                            Email = new MailAddress(emailString),
                            Type  = EmailType.Work
                        };
                        emailAddressCollection.Add(emailAddress);
                    }
                    else
                    {
                        EmailAddress emailAddress = new EmailAddress
                        {
                            Email = new MailAddress(emailString),
                            Type  = EmailType.None
                        };
                        emailAddressCollection.Add(emailAddress);
                    }
                }
                catch (FormatException) { }
            }
            return(emailAddressCollection);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Convert the SMS recipient list from MobilePhone collection type to EmailAddressCollection type.
        /// </summary>
        /// <param name="recipientCollection">Recipient list in a MobilePhone collection type.</param>
        /// <returns>An EmailAddressCollection object containing recipients with "MOBILE" address type. </returns>
        private static EmailAddressCollection ConvertSMSRecipientsFromMobilePhoneCollectionToEmailAddressCollection(Collection<MobilePhone> recipientCollection)
        {
            EmailAddressCollection emailCollection = new EmailAddressCollection(XmlElementNames.Address);
            foreach (MobilePhone recipient in recipientCollection)
            {
                EmailAddress emailAddress = new EmailAddress(
                    recipient.Name, 
                    recipient.PhoneNumber, 
                    RuleActions.MobileType);
                emailCollection.Add(emailAddress);
            }

            return emailCollection;
        }