Need email extractor script

I need a script that can extract all of the “to” and “from” email addresses in a given folder (or from selected messages) in Entourage. I’m trying to build a list of email addresses from a large number of emails.
Is anyone aware of a script that can do this?

This is a fairly fast hack as I just don’t have the time to check which of the zillion Entourage windows can be frontmost. It covers the basics, however. The mail addres of “Me”-contact has to be specified.

tell application "Microsoft Entourage"
	set theWindow to front window
	if class of theWindow = draft window then
		set theRecips to to recipients of theWindow
		set theSender to default email address of me contact
		--end try
		set selectedMessages to current messages
		if selectedMessages is {} then
			display dialog "Please select a (draft) message first and then run this script." with icon 1
		end if
		repeat with theMessage in selectedMessages
			set theSender to sender of theMessage
		end repeat
		set theRecips to default email address of me contact
	end if
end tell
return {theRecips, theSender}

Eelco Houwink

To extract email addresses from text files…
You don’t say if you’re using OS9 or OSX, but if you’re using OSX, then this is a task for Perl & GREP. If you’re using OS9, you may want to use the REGEX scripting addition, which supplies GREP function to applescript, or use BBEdit’s GREP functions.

Thanks for everyone’s help. I got a script working nicely. It dumps the email addresses to a Word document, and it also strips out the duplicates. Thanks.