On 2/6/01 5:14 AM, "pedro" <[EMAIL PROTECTED]> wrote:

> G'day [yet again] Folks
> 
> Just minutes after sending my plea for scripting help I scrolled a couple of
> pages in Micro$oft's Entourage AppleScript reference as I was shutting down
> ... Lo & behold an example in entirely another section set me on the path to
> a solution.  The following snippet sets values in both the to address and
> the subject ...
> 
> tell application "Microsoft Entourage"
>   activate
>   set myNewMsg to make new draft window
>   set myToAddress to (convert "<[EMAIL PROTECTED]>" from text)
>   set to recipients of myNewMsg to myToAddress
>   set subject of myNewMsg to myToAddress
> end tell
> 
> With or without the activate line.
> 
Pedro,

Please explain why you are using the convert verb? perhaps (quite naturally)
you think you need to convert to Unicode from text? No, you don't have to,
it's done automatically. Although Entourage and OE are implemented in
Unicode, unless you actually need it for multilingual operations or 2-byte
languages (in which case just use AppleScript's "as Unicode"), you can treat
all text as text. So if you're making a draft window you can simply say:

tell application "Microsoft Entourage"
    activate
    set myNewMsg to make new draft window
    set myToAddress to  "<[EMAIL PROTECTED]>"
    set to recipients of myNewMsg to myToAddress
    set subject of myNewMsg to myToAddress
end tell


Making outgoing messages, which can be done behind the scenes without seeing
them at all on the screen, is somewhat trickier, particularly in view of the
user-unfriendly (confusing) definitions of Apple's mail Text Suite followed
by Entourage, which has two different terms 'address', one a class, and one
a string property. You can define all necessary properties of all objects at
inception as wellThere is an easy coercion for simple 'to recipients' like
this:

tell application "Microsoft Entourage"
    set myToAddress to "<[EMAIL PROTECTED]>"
    set to recipients of myNewMsg to myToAddress
    set subject of theMsg to myToAddress
    set theContent to "Hello!"
    set theMsg to make new outgoing message at drafts folder with properties
{subject:myToAddress, content: theContent, recipient:{address:myToAddress}}
end tell

But the proper way to to the recipient part, which is a record, and which
you _have_ to do when either specifying a recipient type other than the
default 'to recipient', OR when you have more than one recipient, OR when
you want to include the display name as well as the email address, is like
this:

        set theMsg to make new outgoing message at drafts folder with
properties {subject:myToAddress, content:theContent,
recipient:{{address:{address:myToAddress, display name:"John Smith"},
recipient type:to recipient}, {address:{display name:"Mary Smith",
address:"[EMAIL PROTECTED]"}, recipient type:cc recipient}}} -- all one line

I've used a variety of variable/straight text, etc. for you to see how it
works. 'recipient' is a record of several addresses, each with an 'address'
and 'recipient type' property. Each 'address' in turn is a record with
'address' (sorry!) and 'display name' properties, both of which can be
treated as text (string), even though they're implemented in Unicode.

If anyone has ever wondered why more people don't do AppleScript themselves,
I guess that's the reason! Once you get through some of these intricacies,
it's quite fun.


-- 
Paul Berkowitz


-- 
To unsubscribe:               <mailto:[EMAIL PROTECTED]>
To search the archives: 
          <http://www.mail-archive.com/entourage-talk%40lists.boingo.com/>

Reply via email to