Noob Dictionary Question

Thanks for taking the time to read this question. I’ve been learning applescript and I’m currently trying to write a few scripts involving Entourage 2004 with all the latest MS Office patches installed. I need to create a new outgoing mail message. I accomplished this with the following code segment.


tell application "Microsoft Entourage"
	make new outgoing message
end tell

That was easy. Just incase you are curious here is what it returned:

outgoing message id 48736 of application "Microsoft Entourage"

But how do I address this email? I looked in the dictionary and I see the class recipients is an element of the class “outgoing message.” The class recipients has two properties: address and recipient type. I tried to set the address with the following line:

set address of the recipient of the result to "test@someaddress.com"

but the script throws a runtime error. How do I address an email I’m creating with an applescript?
Oh, I also tried to use an index reference form to address the first recipient but it would not let me build the script with this form. I googled this and found the following code segment:


make new outgoing message at out box folder
            with properties
            {to recipients:"my@email.com"}

This code snip works but why? When I told Applescript to show me all properties for outgoing message (this shows inherited properties too, right?) there was no “to recipients” property. There is a recipient type property and I may be misreading the dictionary but its only options are to to recipient/cc recipient/bcc recipient/newsgroup recipient. The other property “address” takes a string as a parameter but once again, address did not show up when I did a get properties of. I’m curious to know how do you address an existing outgoing email message but my question is how did the person who wrote the previous code get this way of addressing the email from the dictionary? Why won’t my first attempt work? If “to recipients” is not a property what is it? Also, on a side note, when I try to just make an object of type recipient it throws an error. Here is the code:

tell application "Microsoft Entourage"
	make new recipient
end tell

It says it can’t make an object of type recipient. but make is a command in Entourage’s dictionary. How do you know what command works with what objects? Thanks for your help. Let me know if I need to clarify anything.

Model: iMac
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

If you see “outgoing message”, you’ll see “recipient” is an element (as well as a “paragraph” or a “word” could be an element of a “window” or “document” in a text editor).
If you see now the class “recipient”, you will see one of its properties, called “recipient type”, which is an “enumeration” (to recipient, etc.).
The developers, at development time, could had have the idea of implementing these kinds of recipients as separate elements of the class “message” (or “outgoing message”), creating different classes for “to recipient”, “cc recipient” and so on. But they didn’t so.

Soy, you could use this syntax:

tell application "Microsoft Entourage"
	make new outgoing message at outbox folder with properties {subject:"blah", recipient:{recipient type:to recipient, address:{display name:"foo", address:"foo@foo.org"}}}
end tell

BUT you can use as well:

tell application "Microsoft Entourage"
	make new outgoing message at outbox folder with properties {subject:"blah", to recipients:"\"foo\" <foo@foo.org>"}
end tell

The final and concise answer is: read others’ scripts to learn how-to script certain applications. It’s the only way to do it. Dictionaries won’t allways help :confused: