Search This Blog

Tuesday 9 April 2013

find email address in text file using c#


  string data = File.ReadAllText("filepath"); //read File
        //instantiate with this pattern
        Regex emailRegex = new Regex(@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", RegexOptions.IgnoreCase);
        //find items that matches with our pattern
        MatchCollection emailMatches = emailRegex.Matches(data);


        foreach (Match emailMatch in emailMatches)
        {         
            String AnchorLink;
            AnchorLink = "<" + "a href=" + emailMatch.Value + " style="+"text-decoration:underline"+">" + emailMatch.Value + "<a>";
            lblId.Text += data.Replace(emailMatch.Value, AnchorLink);                   
        }      

1 comment:

  1. Find email address is a simple tool to find email that provides a high accurate addressing score. This uses data analysis and cross-checks to provide you with the best result possible.

    ReplyDelete