Noob mail scripting question

I would like to do some website harvesting (as opposed to email harvesting) for a software development mailing list I subscribe to - I want to get a list of websites from the from field of a selected set of email messages, so I can browse them and see what kinds of cool projects are being worked on.

can someone point me in the right direction of where to start and what types of functions to use?

Thanks!

Hi jbrave,

The following AppleScript will scan selected eMail messages in Apple Mail for the domain part of the sender’s address and open the corresponding website URLs in your preferred browser:


on run
	try
		tell application "Mail"
			set selmsgs to selection as list
			if selmsgs is {} then
				error "You did not select any messages in Apple Mail."
				return
			end if
			set websiteurls to {}
			repeat with selmsg in selmsgs
				try
					set mailaddress to extract address from sender of selmsg
					set offsetatsign to offset of "@" in mailaddress
					set domainpart to (characters (offsetatsign + 1) through -1 of mailaddress) as Unicode text
					set websiteurl to "http://www." & domainpart
					set websiteurls to websiteurls & websiteurl
				end try
			end repeat
		end tell
		if websiteurls is {} then
			error "We could not extract any website URLs from the selected messages."
		else
			repeat with websiteurl in websiteurls
				set command to "open " & websiteurl
				do shell script command
			end repeat
		end if
	on error errmsg number errnum
		tell me
			activate
			display dialog "Sorry, an error occured:" & return & return & errmsg & return & "(" & errnum & ")" buttons {"OK"} default button 1 with icon stop giving up after 30
		end tell
	end try
end run

thanks, this worked!

I would like to now modify so that instead of opening urls in a browser, it just dumps a list to a text or html file. For instance: auto-open a new textedit file, and put each url into a vertical list, prefixed with http:// and separated by carriage returns.

Thanks,

Joel