Advertisement
C_Volume2 Data Structures #85277

Email Extraction

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.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
' 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
Original Comments (3)
Recovered from Wayback Machine