Ejemplo n.º 1
0
        private bool HasSpam(EmailNpm emailToValidate)
        {
            var retVal = false;

            if (!string.IsNullOrEmpty(emailToValidate.Message) && emailToValidate.Message.Length < 2000 &&
                emailToValidate.FullName.Length < 200 &&
                emailToValidate.PhoneNumber.Length < 200)
            {
                // Check for Spam Words
                foreach (var word in flaggedAsSpamWord)
                {
                    if (emailToValidate.Message.IndexOf(word, 0, StringComparison.CurrentCultureIgnoreCase) != -1)
                    {
                        // The string exists in the original
                        retVal = true;
                        break;
                    }
                }

                // check for Spam email addresses
                if (!retVal)
                {
                    if (!IsValidEmailAddress(emailToValidate.EmailAddress))
                    {
                        retVal = true;
                    }
                }
            }
            else
            {
                retVal = true;
            }
            return(retVal);
        }
Ejemplo n.º 2
0
        private void SaveMailLocally()
        {
            EmailNpm newEmail = new EmailNpm
            {
                DateSent     = DateTime.Now,
                EmailAddress = this.emailField.Value,
                FullName     = this.NameField.Value,
                Message      = this.bodyField.Value,
                Title        = "N/A",
                PhoneNumber  = this.PhoneField.Value
            };

            if (!HasSpam(newEmail))
            {
                _dataLayer.InsertNewEmail(newEmail);
                contactUsPanel.Visible      = false;
                this.successHolder.Visible  = true;
                this.contactUsError.Visible = false;
            }
            else
            {
                this.contactUsError.Visible = true;
            }
        }