I have about 7 accounts set up in Entourage (office 11.1.1, os 10.3.9).
There are certain addresses that I always want to use to email certain
people. Is there any way to develop something that would coordinate this
for me, or does something already exist?
Say, a script that triggers on Send, and if the address meets a particular
criteria, it sets the from address to a certain account. The criteria, as
far as I am concerned, could be based on individual listings, categories, or
domains. Actually, it looks as though I could set an outgoing rule to run
an applescript on certain categories, but how would the applescript work?
This is particularly annoying when sending attachments from within Word, as
that command always uses my default work address but half the time I am
sending documents to friends I want to use my social address with.
I have a script that runs once a minute and checks the frontmost window. If
it is a draft message window it will check the category of the recipients,
and set the account of the message appropriately.
-- Set Account by Category v1.0 (11th March 2004)
-- created by Barry Wainwright based on an original script by Paul Berkowitz
-- Barry Wainwright <
[email protected]>
-- This script will set the account of a draft message window according to
the category of it's recipients
-- to be most effective, set the script to run from a schedule every minute.
-- set up additional copies of this script to set a different account for
other categories,
-- but beware!: it operates on the first match it comes to, so different
copies
-- of this script checking other categories could cause a loop to be
repeated. This would
-- result in the account being changed every time the script runs.
-- see the 'ReadMe' for additional details
-- version history:
-- v1.0.0 - First Release, 11th March 2004
property recipientCategory : missing value -- draft messages 'to' people in
this category will be processed
property defaultAccount : missing value -- this will hold the account to set
the message to use
on run -- Main Script Routine
if (my checkRecipientCategory()) < -1 then return -- checks the category
is set up
if my checkDefaultAccount() < -1 then return -- checks the account is
set up
tell application "Microsoft Entourage"
-- Process the front window
set frontWindow to window 1
if class of frontWindow is not draft window then return -- only do
something if there's a new draft window open
set oldTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to {","}
set theRecips to (text items of (get to recipients of frontWindow))
& (text items of (get CC recipients of frontWindow))
set AppleScript's text item delimiters to {"<"}
repeat with aRecip in theRecips -- try each recipient in turn
set theRecip to last text item of aRecip -- try and get the
email address
if theRecip ends with ">" then set theRecip to text 1 thru -2 of
theRecip -- it was a full email addres, remove the last brace
set theContacts to find theRecip -- do any contacts have this
email address?
repeat with aContact in theContacts -- there could be more than
one, loop through them
set contactCategory to category of aContact -- get the
categories of the contact
if {recipientCategory} is in contactCategory then -- do they
contain the required category?
-- found a matching category, now deal with the message
set account of frontWindow to defaultAccount
return -- job finished, quit the script
end if -- not in this contact
end repeat -- try next found contact
-- not in the contacts for that address, try next one
end repeat
-- finished all the recipients - no match found, end the script
end tell
end run
on checkDefaultAccount()
-- check to see if a defined defaultAccount has been deleted
tell application "Microsoft Entourage"
try
get defaultAccount
on error --- no such account
set defaultAccount to missing value
end try
-- now check to see if there is an account set up
if defaultAccount = missing value then
-- No account set up
set thenames to {}
repeat with aName in (name of every POP account)
copy aName & " (POP) " to end of thenames
end repeat
repeat with aName in (name of every IMAP account)
copy aName & " (IMAP)" to end of thenames
end repeat
try
set theAccount to item 1 of (choose from list thenames with
prompt "Select the account for the messages:" OK button name "Select"
without multiple selections allowed and empty selection allowed)
on error
-- user cancelled
return -99
end try
if theAccount ends with " (POP) " then
set defaultAccount to POP account (text 1 thru -8 of
theAccount)
else
set defaultAccount to IMAP account (text 1 thru -8 of
theAccount)
end if
end if
end tell
return 0
end checkDefaultAccount
on checkRecipientCategory()
-- check to see if a defined recipientCategory has been deleted
tell application "Microsoft Entourage"
try
get recipientCategory
on error --- no such category
set recipientCategory to missing value
end try
-- Now check to see if a category has been set up
if recipientCategory is missing value then
set theCats to name of every category
try
set recipientCategory to category (item 1 of (choose from
list theCats with prompt "Select the Category for recipient of messages to
be processed:" OK button name "Select" without multiple selections allowed
and empty selection allowed))
on error
-- user cancelled
return -99
end try
end if
end tell
return 0
end checkRecipientCategory