I've 1500 files; each with an email address. I want to retrieve the email
address, put it in a common file and send a reply email.

Re: List email address from multiple files by James

James
Tue Jan 24 16:39:48 CST 2006

"savvy95" <savvy95@discussions.microsoft.com> wrote in message
news:D9CBE8D5-6154-4BEF-80B3-E64BB0CE6421@microsoft.com...
> I've 1500 files; each with an email address. I want to retrieve the email
> address, put it in a common file and send a reply email.

Can you post an example or a detailed explanation of what type of files
you are talking about? Are these plain text files? Are they single or
multiple line files? Also, I assume from your comment above that each file
contains a single email address, is this correct?



Re: List email address from multiple files by savvy95

savvy95
Tue Jan 24 17:06:14 CST 2006

Please excuse my short explanation; I was trying to be
The files are EML files which can be read like TXT files. The files contain
multiple lines; but I'm looking for the email address after "Email :. And you
assumed correctly, I need to parse each file.

"James Whitlow" wrote:

> "savvy95" <savvy95@discussions.microsoft.com> wrote in message
> news:D9CBE8D5-6154-4BEF-80B3-E64BB0CE6421@microsoft.com...
> > I've 1500 files; each with an email address. I want to retrieve the email
> > address, put it in a common file and send a reply email.
>
> Can you post an example or a detailed explanation of what type of files
> you are talking about? Are these plain text files? Are they single or
> multiple line files? Also, I assume from your comment above that each file
> contains a single email address, is this correct?
>
>
>

Re: List email address from multiple files by savvy95

savvy95
Tue Jan 24 17:15:14 CST 2006



"savvy95" wrote:

> Please excuse my short explanation; I was trying to be [direct and complete]. Sorry if I failed; I'll be more attentive.
> The files are EML files which can be read like TXT files. The files contain
> multiple lines; but I'm looking for the email address after "Email :. And you
> assumed correctly, I need to parse each file.
>
> "James Whitlow" wrote:
>
> > "savvy95" <savvy95@discussions.microsoft.com> wrote in message
> > news:D9CBE8D5-6154-4BEF-80B3-E64BB0CE6421@microsoft.com...
> > > I've 1500 files; each with an email address. I want to retrieve the email
> > > address, put it in a common file and send a reply email.
> >
> > Can you post an example or a detailed explanation of what type of files
> > you are talking about? Are these plain text files? Are they single or
> > multiple line files? Also, I assume from your comment above that each file
> > contains a single email address, is this correct?
> >
> >
> >

Re: List email address from multiple files by James

James
Tue Jan 24 20:43:58 CST 2006

"savvy95" <savvy95@discussions.microsoft.com> wrote in message
news:A81777AF-EA8E-4113-A4EE-0DCEB2D0D273@microsoft.com...
> Please excuse my short explanation; I was trying to be
> The files are EML files which can be read like TXT files. The files
contain
> multiple lines; but I'm looking for the email address after "Email :. And
you
> assumed correctly, I need to parse each file.

Give the below code a try and see if it does what you are looking for. It
is a little rough, so you might have to post back with the error message(s)
and/or undesired results. Make sure to customize the variables on lines 13 &
14 for your environment.

The code below only addresses the first part of your problem. If it works,
we can move on to part 2. Also, when I saved out some email message from
Outlook Express, I did not have an "Email: " header, but rather a "From: "
header, so that is the way I wrote the code. If your EML messages actually
use "Email: ", alter line 11.

Lastly, please consider that using regular expressions to match email
addresses is somewhat dubious. It will probably work for most email
addresses, but might misidentify some. See this thread for some recent
discussions of this issue: http://tinyurl.com/a2c9q

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim oFSO, sFolder, oFolder, oFile, oInpFile, sOutFile
Dim oOutFile, oRegEx, sEmlFileText

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oRegEx = CreateObject("VBScript.RegExp")

oRegEx.IgnoreCase = True
oRegEx.MultiLine = True

oRegEx.Pattern = "^From:.*\b([\w!#$%&'*+-./=?^`{|}~]+@[\w-.]+)"

sFolder = "C:\Emails\"
sOutFile = "C:\Email Addresses.txt"

Select Case oFSO.FolderExists(sFolder)
Case True Set oFolder = oFSO.GetFolder(sFolder)
Case Else
MsgBox "Folder """ & sFolder & """ does not exist."
End Select

Set oOutFile = oFSO.OpenTextFile(sOutFile, 2, True)

For Each oFile in oFolder.Files
Set oInpFile = oFSO.OpenTextFile(oFile, 1)
sEmlFileText = oInpFile.ReadAll
If oRegEx.Test(sEmlFileText) Then
oOutFile.WriteLine oRegEx.Execute(sEmlFileText)(0).Submatches(0)
End If
oInpFile.Close
Next

oOutFile.Close

MsgBox "Done"
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Re: List email address from multiple files by savvy95

savvy95
Wed Jan 25 07:11:03 CST 2006

Thank you James.

After modifying the locations, I tried the code; but got the following error:
Input past end of file
code:8000A003E
Line:26

Line 26 is
sEmlFileText = oInpFile.ReadAll




"James Whitlow" wrote:

> "savvy95" <savvy95@discussions.microsoft.com> wrote in message
> news:A81777AF-EA8E-4113-A4EE-0DCEB2D0D273@microsoft.com...
> > Please excuse my short explanation; I was trying to be
> > The files are EML files which can be read like TXT files. The files
> contain
> > multiple lines; but I'm looking for the email address after "Email :. And
> you
> > assumed correctly, I need to parse each file.
>
> Give the below code a try and see if it does what you are looking for. It
> is a little rough, so you might have to post back with the error message(s)
> and/or undesired results. Make sure to customize the variables on lines 13 &
> 14 for your environment.
>
> The code below only addresses the first part of your problem. If it works,
> we can move on to part 2. Also, when I saved out some email message from
> Outlook Express, I did not have an "Email: " header, but rather a "From: "
> header, so that is the way I wrote the code. If your EML messages actually
> use "Email: ", alter line 11.
>
> Lastly, please consider that using regular expressions to match email
> addresses is somewhat dubious. It will probably work for most email
> addresses, but might misidentify some. See this thread for some recent
> discussions of this issue: http://tinyurl.com/a2c9q
>
> '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Dim oFSO, sFolder, oFolder, oFile, oInpFile, sOutFile
> Dim oOutFile, oRegEx, sEmlFileText
>
> Set oFSO = CreateObject("Scripting.FileSystemObject")
> Set oRegEx = CreateObject("VBScript.RegExp")
>
> oRegEx.IgnoreCase = True
> oRegEx.MultiLine = True
>
> oRegEx.Pattern = "^From:.*\b([\w!#$%&'*+-./=?^`{|}~]+@[\w-.]+)"
>
> sFolder = "C:\Emails\"
> sOutFile = "C:\Email Addresses.txt"
>
> Select Case oFSO.FolderExists(sFolder)
> Case True Set oFolder = oFSO.GetFolder(sFolder)
> Case Else
> MsgBox "Folder """ & sFolder & """ does not exist."
> End Select
>
> Set oOutFile = oFSO.OpenTextFile(sOutFile, 2, True)
>
> For Each oFile in oFolder.Files
> Set oInpFile = oFSO.OpenTextFile(oFile, 1)
> sEmlFileText = oInpFile.ReadAll
> If oRegEx.Test(sEmlFileText) Then
> oOutFile.WriteLine oRegEx.Execute(sEmlFileText)(0).Submatches(0)
> End If
> oInpFile.Close
> Next
>
> oOutFile.Close
>
> MsgBox "Done"
> '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
>

Re: List email address from multiple files by savvy95

savvy95
Wed Jan 25 07:16:03 CST 2006

Disregard previous message. I fixed by having the emails and the output file
in different directories. It works fine now.

So now I've retrieved a list of email addresses. I guess the next step is
to email the list with a canned response. No?



"James Whitlow" wrote:

> "savvy95" <savvy95@discussions.microsoft.com> wrote in message
> news:A81777AF-EA8E-4113-A4EE-0DCEB2D0D273@microsoft.com...
> > Please excuse my short explanation; I was trying to be
> > The files are EML files which can be read like TXT files. The files
> contain
> > multiple lines; but I'm looking for the email address after "Email :. And
> you
> > assumed correctly, I need to parse each file.
>
> Give the below code a try and see if it does what you are looking for. It
> is a little rough, so you might have to post back with the error message(s)
> and/or undesired results. Make sure to customize the variables on lines 13 &
> 14 for your environment.
>
> The code below only addresses the first part of your problem. If it works,
> we can move on to part 2. Also, when I saved out some email message from
> Outlook Express, I did not have an "Email: " header, but rather a "From: "
> header, so that is the way I wrote the code. If your EML messages actually
> use "Email: ", alter line 11.
>
> Lastly, please consider that using regular expressions to match email
> addresses is somewhat dubious. It will probably work for most email
> addresses, but might misidentify some. See this thread for some recent
> discussions of this issue: http://tinyurl.com/a2c9q
>
> '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Dim oFSO, sFolder, oFolder, oFile, oInpFile, sOutFile
> Dim oOutFile, oRegEx, sEmlFileText
>
> Set oFSO = CreateObject("Scripting.FileSystemObject")
> Set oRegEx = CreateObject("VBScript.RegExp")
>
> oRegEx.IgnoreCase = True
> oRegEx.MultiLine = True
>
> oRegEx.Pattern = "^From:.*\b([\w!#$%&'*+-./=?^`{|}~]+@[\w-.]+)"
>
> sFolder = "C:\Emails\"
> sOutFile = "C:\Email Addresses.txt"
>
> Select Case oFSO.FolderExists(sFolder)
> Case True Set oFolder = oFSO.GetFolder(sFolder)
> Case Else
> MsgBox "Folder """ & sFolder & """ does not exist."
> End Select
>
> Set oOutFile = oFSO.OpenTextFile(sOutFile, 2, True)
>
> For Each oFile in oFolder.Files
> Set oInpFile = oFSO.OpenTextFile(oFile, 1)
> sEmlFileText = oInpFile.ReadAll
> If oRegEx.Test(sEmlFileText) Then
> oOutFile.WriteLine oRegEx.Execute(sEmlFileText)(0).Submatches(0)
> End If
> oInpFile.Close
> Next
>
> oOutFile.Close
>
> MsgBox "Done"
> '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
>

Re: List email address from multiple files by James

James
Wed Jan 25 07:36:16 CST 2006

"savvy95" <savvy95@discussions.microsoft.com> wrote in message
news:E6A21E7C-16BB-410A-9B62-87804D974533@microsoft.com...
> Disregard previous message. I fixed by having the emails and the output
file
> in different directories. It works fine now.
>
> So now I've retrieved a list of email addresses. I guess the next step is
> to email the list with a canned response. No?

One thing I forgot to ask in my first response: Do you want to eliminate
duplicates? The code as it stands now adds each email address to the list.
If 25 of your 1500 files contains "joe@somewhere.com", that address will
appear in the output file 25 times. We could use a dictionary object to
prevent this is you like. Since I don't know your needs, I don't know
whether or not you would want 25 replies sent to the same email address or
not.