Re: Scripting Entourage
Re: Scripting Entourage
- Subject: Re: Scripting Entourage
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 04 Dec 2001 10:50:00 -0800
On 12/4/01 10:01 AM, "John H Moody" <email@hidden> wrote:
>
I'm trying to create a script which populates Microsoft Entourage's "to"
>
recipient field with a pre-determined email address. Based on Entourage's
>
dictionary, my script so far looks like this:
>
>
>
Set x to "email@hidden"
>
>
Tell application "Microsoft Entourage"
>
activate
>
make new draft window
>
set to recipients to x
>
End tell
>
>
Entourage launches and opens a new draft window just fine, but results with
>
the error "Microsoft Entourage got an error: Can't set to recipients to
>
"email@hidden".
>
>
If anyone has any experience with scripting Entourage, I'd be greatly
>
appreciative of any advice.
>
As with applescripting of any application, you have to use what's called the
'object model' correctly. You can't just set an abstract agglomeration of
'to recipients' to anything, but you _can_ set the 'to recipients' of a
particular draft window to any properly-formatted string (text) of email
addresses. If you look in the Dictionary, as I think you must have. you see
that 'to recipients' is a property of 'draft window', not of the world at
large. Sp there has to be a 'to recipients of [a particular] draft window'
There's more than one way to do it. Making a blank draft window, as you did
then changing the to recipients, is one way. In that case you have to
specify the particular draft window by setting a variable to it, so you can
refer to it again:
set x to "email@hidden"
tell application "Microsoft Entourage"
activate
set theWindow to make new draft window
set to recipients of theWindow to x
end tell
Or you can do it all in one fell swoop by setting the properties of the
window as you create it:
tell application "Microsoft Entourage"
activate
make new draft window with properties {to recipients:x}
end tell
That has the advantage that you can insert as many other properties as you
wish all at the same time. Since you may then want to do something else with
the window, such as sending or saving it, it's still a good idea to set a
variable to it however:
set toRecips to "email@hidden"
set ccRecips to "Someone Else <email@hidden>, And Another
<email@hidden>" -- one line
set theSubject to "How's that?"
set theContent to "Here's some interesting stuff. Blah."
tell application "Microsoft Entourage"
set theAccount to POP account 2 -- or POP account "Name of Account"
set theWindow to make new draft window with properties
{subject:theSubject, account:theAccount, content:theContent, to
recipients:toRecips, CC recipients:ccRecips} -- one long line
send theWindow
end tell
(Watch out for line breaks inserted by this email. Get rid of them.)
Signatures and attachments are more complicated.
Hope this gives you the idea.
--
Paul Berkowitz