Extracting sender from Entourage / parsing text

Hi, I’m new, hope y’all don’t make fun of me.

I’m trying to write a simple script in Entourage that will enable me to make a quick list of people who have emailed me on a certain topic, so I can send them information via snail mail.

I’m 99% of the way there. I have a script that gets the “sender” property from Entourage and appends it to a file. Like this:

repeat with theMessage in selectedMessages
set thesender to sender of theMessage
copy thesender to end of AllSenders

and then on to a file. So far it works perfectly, except for one problem – there’s a lot of unneeded characters that are included in that “sender” variable – like reco

I got it to work… here’s what I started with:


..snip declarations...

repeat with theMessage in selectedMessages
		
		-- get the information from the message, and store it in variables
		set addresssender to display name of sender of theMessage
		copy addresssender to end of AllSenders
		copy {"		"} to end of AllSenders
	end repeat
	
	try
		
		set theFile to choose file name default name "Sender Export"
		open for access theFile with write permission
		set eof theFile to 0
		write AllSenders to theFile
		close access theFile
		
	end try

 

##########

And here’s what I ended up with:


	set selectedMessages to current messages
	set AllSenders to {} as list
	set AllNames to {} as list
	set addresssender to {}
	set messagenum to 0 as integer
	set displaynum to 2 as integer
	set recordseparator to return

	repeat with theMessage in selectedMessages
		
		-- get the information from the message, and store it in variables
		set Tempsender to address of sender of theMessage
		set AllSenders to AllSenders & "	" & Tempsender as list
		set messagenum to messagenum + 1
	end repeat
	
	set dialognum to "Email Addresses Harvested: " & messagenum
	display dialog dialognum
	
	try
		
		set theFile to choose file name default name "Sender Export"
		open for access theFile with write permission
		set eof theFile to 0
		repeat messagenum times
			set FinalSenders to text item displaynum of AllSenders
			set displaynum to displaynum + 2
			write FinalSenders to theFile
			write recordseparator to theFile
		end repeat
		
		close access theFile
		
	end try
 

For some reason concatenating the results together corrupted that variable with all sorts of garbage – like “TEXT!!” between each result, while writing each one to the file one at a time didn’t. Dunno, I just tried a bunch of things until this worked.

I have a feeling this was some classic newbie stuff and I should have known better how to create string that’s a list of text terms. But hey, it works… posting in case who knows maybe someone else like me wanders along in the distant future.

  • El Flailey