Entourage addresses

We have a couple of Entourage ‘housekeeping’ functions we’d like to automate and I’ve been reliably informed that AppleScript is the way to go. Unfortunately, my scripting skills are inadequate for this job, but we’d be happy to pay for professional help.

  1. As a one-off, we’d like to extract recipient names and email addresses from the Sent Mail folder. I’ve tried a couple of third-party tools (MailJuicer and eMail Extractor X) but they don’t fit the bill.

  2. We have a user with a POP account who would like to have the name and email address of people he replies to checked against his Entourage address book (which currently has around 1300 entries) and if it’s not in there, have it added automatically.

(Entourage 2004)
#1: extract recipients of sent-items folder’s messages

set adds to {}
tell application "Microsoft Entourage"
	repeat with i in (get recipients of messages of folder "Sent Items")
		repeat with x from 1 to count i
			set adds's end to address of (i's item x)
		end repeat
	end repeat
end tell
adds --> {{address:"foo@foo.com", display name:"Mr. Foo"},{address:"bar@bar.net",display name:"Mr. Bar"}}

#2: add to Address Book any recipients in sent-items folder whose email address is not in Address Book

set adds to {}
tell application "Microsoft Entourage"
	set AddresBookAddresses to contacts's address
	repeat with i in (get recipients of messages of folder "Sent Items")
		repeat with x from 1 to count i
			set recipientAddress to address of (i's item x)
			set z to address of recipientAddress
			if z is not in AddresBookAddresses then
				if z is not in adds then
					set adds's end to z
					make new contact with properties {display name:display name of recipientAddress, address:z}
				end if
			end if
		end repeat
	end repeat
end tell