Dim fso,textstr,contents
Set fso = createobject("scripting.filesystemobject")
set textstr = fso.OpenTextFile( InputBox("textfile to search in?"), 1,False)
contents = textstr.ReadAll
WScript.echo retrieveEmails(contents)
Function retrieveEmails(input)
Dim regexp,matches,match,output
set regexp = New regexp
regexp.pattern="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
regexp.ignorecase=True
regexp.global=True
set matches= regexp.Execute(input)
For Each match In matches
output & output & match.value & vbcrlf
Next
retrieveEmails = output
End Function