Getting Entourage 2004 e-mail recipent

Hello list, I am trying to write a short AppleScript that will extract several properties of an e-mail in Entourage 2004 to produce a summary and put it on the clipboard. I can get all of the properties of the e-mail message I want except the recipient of the e-mail. I get error messages when I try to get that property. I have tried to work around it using try statements and typing in the recipient after I paste the summary just to make it work, but would like to get the whole summary in one piece. Any ideas?

If I remove the “try” statement from
try
set emailRecipient to the address of the recipient of theMsg as text
end try
then I get this error: Can’t make «class addr» of «class rcpt» of «class inm » id 100723 of application “Microsoft Entourage” into type string.

If I remove “as text” then I get this error: Microsoft Entourage got an error: Can’t get address of recipient of incoming message id 100723.

It almost seems like Entourage is blocking me. Are there any Entourage scripting wizards that know a way to do this?

Here is the script:


set emailSender to ""
set emailDate to ""
set emailRecipient to ""
set emailSubject to ""
set emailContent to ""

tell application "Microsoft Entourage"
	activate
	
	try
		if window 1 = main window then
			set theMsg to item 1 of (get current messages)
		end if
	end try
	
	try
		set emailSender to the address of the sender of theMsg
	end try
	try
		set emailDate to the time sent of theMsg
	end try
	try
		set emailRecipient to the address of the recipient of theMsg as text
	end try
	try
		set emailSubject to the subject of theMsg
	end try
	try
		set emailContent to the content of theMsg
	end try
	
	set citation to "From: " & emailSender & return & "Date: " & emailDate & return & "To: " & emailRecipient & return & "Subject: " & emailSubject & return & return & emailContent as text
	
	set the clipboard to citation as text
	
end tell

Model: MacPro 3.0 GHz Quad
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Hi,

two problems:
recipient is an element (a list) not a string, so you should take one item like “recipient 1”
address of recipient is also an element (a list) which contains the properties display name and address
(address of address is quite confusing, but it’s correct, thank you, Microsoft ;))

Try this:

set emailSender to ""
set emailDate to ""
set emailRecipient to ""
set emailSubject to ""
set emailContent to ""

tell application "Microsoft Entourage"
	activate
	if window 1 = main window then
		set theMsg to item 1 of (get current messages)
	end if
	
	tell theMsg
		set emailSender to the address of the sender
		set emailDate to the time sent
		tell address of recipient 1 to set emailRecipient to its display name & space & "<" & its address & ">"
		set emailSubject to the subject
		try
			set emailContent to the content
		end try
	end tell
	set citation to "From: " & emailSender & return & "Date: " & emailDate & return & "To: " & emailRecipient & return & "Subject: " & emailSubject & return & return & emailContent as text
	
	set the clipboard to citation
	
end tell

Stefan is the man of the hour! His revision of my script worked perfectly. Thank you Stefan!

I had an inkling that there was more to the address than meets the eye. I tried “address of address” in other versions of this script, and “to recipient of address” and “display name of address” but never quite got it.

What if you have more than 1 recipient?