Title: Re: Entourage Applescript Help... (to: field)
On 14/12/01 9:27 pm, "Domains4Days.com" <[EMAIL PROTECTED]> wrote:

> For incoming mail : I can't seem to find the command to get the "to:" field
> in a message.... (to put on the clipboard)
>
> tell application "Microsoft Entourage"
>   set theMessage to the displayed message of the front window
>   
>   set theSender to sender of theMessage
>   
>   set towho to ???account/or/recipient??? of theMessage
>   
>   set the clipboard to theSender & "-" & towho
>   
> end tell

First place to look is in the Entourage Applescript Dictionary. Get this by choosing the menu item 'open dictionary' if you're using Apple's Script Editor or Smile.

This shows that an 'incoming Message' is defined as having an element called 'recipient' which can be got by index (first recipient, recipient 2, etc) or by test (recipients whose x is y).

Class incoming message : (inherits from message) An incoming e-mail message
Plural form:
   incoming messages
Elements:
   attachment by numeric index, test
   recipient by numeric index, test

Now, look further on in the dictionary and see how a recipient is defined. It says this:

Class recipient : Message recipient
Plural form:
   recipients
Properties:
   address address -- the recipient's address
   recipient type to recipient/cc recipient/bcc recipient/newsgroup recipient -- the type of recipient

So, it has two properties – an address (of type ‘address’, so we need to look back at the disctionary again), and the ‘recipient type’ .

Now, tie this in with the ‘recipient by test’ of the Incoming Message class and we start to get somewhere:

recipients of theMess whose recipient type is to recipient
  --  {recipient 1 of incoming message id 29730}

Note that the value returned is a list! This is because there could be more than one ‘to recipient’!

Now, remember what we said about the addresses? We need to look back into the dictionary to see how the ‘address’ class is defined:

Class address : An e-mail message address
Plural form:
   addresses
Properties:
   display name Unicode text -- the name used for display
   address string -- the e-mail address

Here it can get a little confusing. CLASS address has a property called ‘address’ that is of type string. The authors of Entourage could possibly have chosen a better phrase here to make thingsd a little clearer (“address string” or “email address”?), but still, we have to work with what we’ve got.

Now,’
recipients of theMess whose recipient type is to recipient’ got us a reference to a list of recipients ({recipient 1 of incoming message id 29730}). We can ask for their addresses, which will get us the entire record:

address of (recipients of theMess whose recipient type is to recipient)
  --  {{address:"[EMAIL PROTECTED]", display name:"Entourage mac Talk"}}

Or, you can ask for the bit you want:

address of address of (recipients of theMess whose recipient type is to recipient)
  --  {"[EMAIL PROTECTED]"}

Display name  of address of (recipients of theMess whose recipient type is to recipient)
  --  {"Entourage mac Talk"}

This is the information you were after! Remember that it is still in list form and there could be more than one. There could also be less than one! (messages without a ‘to’ recipient are valid!), so some testing will prevent a script error when you try to get properties of recipients that are not present.

I hope this helps you get the information you wanted for your script and also to learn how to interpret the AS dictionaries. Digging in the dictionary can be the best way to learn just what can be done in an application. That of course, relies on the dictionary being well written. Fortunately, with just one or two small exceptions, the Entourage dictionary is one of the best in existence, and is well worth perusing.
HTH!


--
Barry Wainwright
<http://www.barryw.net>


When choosing between two evils, I like to
choose the one I've never done before.

Reply via email to