VB icon

Email Extraction

Email
Submitted on: 1/2/2015 8:13:00 AM
By: sUPErX1 (from psc cd)  
Level: Beginner
User Rating: By 5 Users
Compatibility: VB.NET
Views: 1071
 
     The is the first of its kind that i have seen. It extracts emails from the c:\program files directory and subdirectorys please vote for me if this is of use to you.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Email Extraction
// Description:The is the first of its kind that i have seen. It extracts emails from the c:\program files directory and subdirectorys please vote for me if this is of use to you.
// By: sUPErX1 (from psc cd)
//**************************************

' This programme was created by Damien Hally
' Please if you find this programme useful Vote For Me
'
'This programme searches for emails in the programs folder and subfolders
' for emails and sxtracts them into a file on the c:\ drive called name.txt
Imports System.IO
Imports System
Imports Microsoft.VisualBasic
Imports System.Text.RegularExpressions
Module Module1
Sub main()
On Error Resume Next
Dim fname As String
Dim tx As String
Dim dname As String
Dim hd As New FileStream("c:\name.txt", FileMode.OpenOrCreate, FileAccess.Write)
Dim dh As New StreamWriter(hd)
For Each dname In Directory.GetDirectories("c:\program files")
For Each fname In Directory.GetFiles((dname), "*.txt")
Dim sr As New FileStream((fname), FileMode.Open, FileAccess.Read)
Dim str As New StreamReader(sr)
str.BaseStream.Seek(0, SeekOrigin.Begin)
tx = str.ReadToEnd()
Dim re As New Regex("[\w\-]+\@[\w\-]+\.\b[\S\-]+\b", RegexOptions.IgnoreCase)
Dim m As Match = re.Match(tx)
Do While m.Success
dh.WriteLine(m)
m = m.NextMatch
Loop
str.Close()
Next
Next
dh.Close()
End Sub
End Module


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

7/8/2015 4:20:19 PMsharx

i want to extract the mail into my text boxes and listview in my application

(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.