Email address extractor for 'Reply-To' field

Hi Everyone,

I have been using an email address extractor Applescript that works perfectly to extract addresses from the ‘sender’ in Mail. Because of the way I now have the web form set up, I now need to extract the email addresses from the ‘reply-to’ field in Mail. Is it possible to modify this Applescript (the one I have been using) to do this?

tell application "Mail"
	set selectionMessage to selection -- just select the first message in the folder
	set thisMessage to item 1 of selectionMessage
	set theseMessages to (every message in (mailbox of thisMessage))
	
	repeat with eachMessage in theseMessages
		set theFrom to (extract address from sender of eachMessage)
		do shell script "echo " & quoted form of theFrom & return & " >> ~/desktop/extracted.txt"
	end repeat
end tell

Thanks for looking!

I think all you need to do is change “sender” to “reply to.”


tell application "Mail"
	set selectionMessage to selection -- just select the first message in the folder
	set thisMessage to item 1 of selectionMessage
	set theseMessages to (every message in (mailbox of thisMessage))
	
	repeat with eachMessage in theseMessages
		set theFrom to (extract address from reply to of eachMessage)
		do shell script "echo " & quoted form of theFrom & return & " >> ~/desktop/extracted.txt"
	end repeat
end tell

Ah, that’s very neat! When I tried that from within Applescipt.app I couldn’t make it work! Thanks so much. Works perfectly!