public static int GetMails(string source) { int count = 0; string htmlMatch = TextUtils.GetPageSource(source); if (string.IsNullOrEmpty(htmlMatch)) { return(0); } Regex regex = new Regex(@"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?"); MatchCollection matches = regex.Matches(htmlMatch); foreach (Match match in matches) { bool isValid = TextUtils.ValidateMail(match.Value); if (isValid) { string email = match.Value.Trim().ToLower(); email = TextUtils.ClearEmail(email); EmailRow emailRow = BLL.GetEmail(email); if (emailRow == null) { if (CreateEmail(email)) { count++; } } } } return(count); }
internal static List <EmailRow> GetCVMails() { DataTable rows = null; using (SqlConnection con = DbUtilsDal.OpenConnection(DbUtilsDal.MainDB)) { rows = DbUtilsDal.ExecuteDataTable(con, "dbo.GetCVMails"); } return(EmailRow.ToListEmailRows(rows)); }
internal static EmailRow GetEmail(string email) { DataRow row = null; using (SqlConnection con = DbUtilsDal.OpenConnection(DbUtilsDal.MainDB)) { row = DbUtilsDal.ExecuteDataRow(con, "dbo.GetEmail", new string[] { "@Email" }, new SqlDbType[] { SqlDbType.VarChar }, new object[] { email }); } return(EmailRow.ToEmailRow(row)); }
public static EmailRow ToEmailRow(DataRow row) { EmailRow email = null; if (row != null) { email = new EmailRow(); if (row["Email"] != null) { if (!string.IsNullOrEmpty(row["Email"].ToString())) { email.Email = row["Email"].ToString(); } } } return(email); }