I'm having a little AppleScript trouble and I'm hoping someone can point out the probably obvious error of my ways.
I have the following script:
--begin script
property theAddress : "remo @ mac.com"
property theRecipient : "[EMAIL PROTECTED]"
tell application "Microsoft Entourage"
set thesubject to "Test Subject"
set theBody to "Test body"
make new draft window with properties {subject:thesubject, content:theBody, account:theAddress, to recipients:theRecipient}
end tell
--end script
As you can see, I’m trying to define the account to send the message from by name, but I’m failing at either defining the "theAddress" property or the property of the draft window correctly or both. As written, the script compiles, but errors with the following when run:
Microsoft Entourage got an error:
Expected a reference
With the error occurring in the "make new draft window" line. If I remove "account:theAddress," the script runs fine, but the draft window has the default account. Could some kind soul explain the correct syntax for this? I'd prefer to define the sending account by name rather than having to figure out the ID of the account (besides, wouldn't the ID change if the database were rebuilt?).
Thank you.
-Remo Del Bello
I don't think you've told us the name of your account, have you? Do you use the email address (maybe with those strange space around the"@"?) also as the name of the account as seen in Tools/Accounts?
Assuming that "[EMAIL PROTECTED]" is in fact the name of the account, you nevertheless do have to specify the 'account' property as an account, not just a string. Sure you can specify the account by name, but it still has to be an account so specified:
POP account "[EMAIL PROTECTED]"
or
IMAP account "[EMAIL PROTECTED]"
as the case may be, and not simply
"[EMAIL PROTECTED]"
which is just a string.
I would never do this myself - omitting error traps in case you've changed the name of the account or deleted it it, but here it is without using any variables, just hard-coded in:
--begin script
tell application "Microsoft Entourage"
make new draft window with properties {subject:"Test Subject", content:"Test body", account:IMAP account "[EMAIL PROTECTED]", to recipients:"[EMAIL PROTECTED]"}
end tell
--end script
And here it is with properties and variables:
--begin script
property theAddress : "[EMAIL PROTECTED]"
property theRecipient : "[EMAIL PROTECTED]"
tell application "Microsoft Entourage"
set thesubject to "Test Subject"
set theBody to "Test body"
set theAccount to IMAP account theAddress
make new draft window with properties {subject:thesubject, content:theBody, account:theAccount , to recipients:theRecipient}
end tell
--end script
If you're using the default mail account, you can just omit all mention of the account.
--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page: http://www.entourage.mvps.org/toc.html
PLEASE always state which version of Entourage you are using - 2001 or X. It's often impossible to answer your questions otherwise.
