Applescript and Accounts, Entourage 2004

J

John Graf

Hi, All,

I am far from an Applescript expert, but I have managed to fumble along and
create a few scripts that help me automate certain email replies. These
scripts worked great under Entourage X, but now with Entourage 2004 I have a
problem.

Under Entourage X, I could set the outgoing email account with a simple "set
theSender to [email protected]" and it would use the account with that email
address. Now, however, all email originates from the default account
regardless of what I set the sender to.

Has anyone seen this or figure out a work-around?

Thanks,

JG
 
P

Paul Berkowitz

I am far from an Applescript expert, but I have managed to fumble along and
create a few scripts that help me automate certain email replies. These
scripts worked great under Entourage X, but now with Entourage 2004 I have a
problem.

Under Entourage X, I could set the outgoing email account with a simple "set
theSender to [email protected]" and it would use the account with that email
address.

You took advantage of a bug.
Now, however, all email originates from the default account
regardless of what I set the sender to.

Has anyone seen this or figure out a work-around?

Just set the account, not the sender, of the message or draft window. All
your accounts have names - go take a look at them in Tools/Accounts/Mail.
Some people give their accounts the email address itself as a name, others
use more fanciful or descriptive names. (The name for the account I use here
is "Spoof Silcom", for example.) You also have to know whether it's a POP or
IMAP or Hotmail or Exchange account, since those are all separate classes in
Entourage scripting (no 'account' superclass, although there is an 'account'
property of 'message' and 'draft window').

So:

set account of theMsg to POP account "Whatever it's called"

if the message or draft window already exists (as it sounds) and you've set
the variable 'theMsg' to it previously.

Or you can do it at inception

set theAcct to POP account "Whatever it's called"
set theMsg to make new outgoing message with properties
{account:theAcct, content:"Boo",... etc.}


--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page: <http://www.entourage.mvps.org/toc.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Entourage you are using - **2004**, X
or 2001. It's often impossible to answer your questions otherwise.
 
J

John Graf

That worked like a champ. I had tried setting the account but was unaware
of the separate classes for POP, IMAP and Exchange. Thanks for the answer!
 
B

Bill Weylock

What about using one account for business and one for friends? In Eudora,
it's trivial.

Is there a workaround for that?
 
P

Paul Berkowitz

What about using one account for business and one for friends? In Eudora,
it's trivial.

Is there a workaround for that?

It doesn't need a workaround. Just do it. You can get as many accounts as
you need from your ISP and set each one up in Tools/Accounts separately.

Or you can set up a "dummy" account - sending only - with the same SMTP
address and no POP address. You can send to that one, but you'd have to set
up a redirection on the POP server (not in Entourage) to re-direct to your
regular POP address. Then have an Entourage rule that if the dummy address
were one of the "To" recipients, file it in a different folder. When
replying, you'd have to remember to switch to the dummy account. Or use my
"Reply Rerouted Account X" script which is designed for such situations - it
will know automatically which account to send from. You can get the script
at

MacScripter.net <http://macscripter.net/scriptbuilders/>



--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page: <http://www.entourage.mvps.org/toc.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Entourage you are using - **2004**, X
or 2001. It's often impossible to answer your questions otherwise.
 
B

Bill Weylock

You're of course right again. The To/CC/Bc window was covering up just
enough of the main composition window for me not to notice that there was a
selection tab for ³From² as well. It works just the way Eudora did.

And I long ago set up separate email boxes on my domain host site.

On Eudora I could set up a Filter (Rule) to change Personality (Account)
based on criteria for an incoming email. So email addressed to PersonsalBill
went out from [email protected], while BusinessBill mail replies were from
[email protected]. I¹m betting I can figure out how to do the same thing here.
 
B

Barry Wainwright

On Eudora I could set up a Filter (Rule) to change Personality (Account) based
on criteria for an incoming email. So email addressed to PersonsalBill went
out from [email protected], while BusinessBill mail replies were from
[email protected]. I¹m betting I can figure out how to do the same thing here.

Correct, there is no direct way to do this with rules - It's something I
have requested many times. Perhaps you would like to do the same?

You can send feedback to the developers on this issue. Use the last menu
item under the 'Help' menu - "Send Feedback on Entourage". This message will
go directly to the developers. The more people that request this feature the
more likely it is to be implemented.


However - the fix - just use a rule to run an applescript. This one does a
bit of error checking, and can be run manually on selected messages, or as
the action to a mail rule:

Property accountName: "name_of_your_account"
tell application "Microsoft Entourage"
set accList to (every POP account whose name contains accountName)
if accList = {} then
display dialog "No Account defined!" buttons {"Quit"} default button
1 with icon stop
return
else
set theAcc to item 1 of accList
set messList to current messages
if messList = {} then
display dialog "No messages selected!" buttons {"Quit"} default
button 1 with icon stop
return
else
repeat with aMess in messList
set account of aMess to theAcc
end repeat
end if
end if
end tell
 
J

John Graf

I've discovered some interesting things while reworking these Entourage X
Scripts to Entourage 2004:

The following script results in a BLANK message, although the account of the
outgoing message does change:

tell application "Microsoft Entourage"

set theAccount to POP account "Test"
set selectedMessages to the selection
repeat with eachMessage in selectedMessages
set theContents to newContents
set theSubject to "Re: " & the subject of eachMessage
set theRecipient to sender of eachMessage
set this_message to make new outgoing message with properties ¬
{content:theContents,recipient:theRecipient,
subject:theSubject,account:theAccount}

I've tried variations, but the message is always blank. If I do NOT set the
account, the message is sent from the default account but the contents are
there.

Another interesting item:

I can change the default account in the script and send the message. That
works. For example:

Set default mail account to POP account "Test"

HOWEVER, I cannot change the default mail account back to an Exchange
account, for example, the following will NOT work:

Set default mail account to Exchange account "Test1"

Are these bugs or am I missing something here?

Thanks.
 
B

Barry Wainwright

I've discovered some interesting things while reworking these Entourage X
Scripts to Entourage 2004:

The following script results in a BLANK message, although the account of the
outgoing message does change:

tell application "Microsoft Entourage"

set theAccount to POP account "Test"
set selectedMessages to the selection
repeat with eachMessage in selectedMessages
set theContents to newContents

I presume that 'newContents' does hold some value?
 
Top