OK I have a fairly elaborate Apple script going for exporting emails
from Entourage to a specific hard coded folder on my hard drive.

The problem I am running into and cannot seem to solve is this: My
script can only select the default folders of "Folders on My
Computers" rather than the Exchange account that I have. All else in
the rest of the scipt which is now quite lengthy, works exactly the
way I want it to except this part. Can anyone shed light on what I am
doing wrong?

Disclaimer: I did not write all of this rather I gathered bits and
pieces and wrote the parts I needed to make it work for me.
Specifically Paul's advice in this thread has proven most valuable:

http://groups.google.com/group/microsoft.public.mac.office.entourage/browse=
_frm/thread/3d09a8462c1f314d/c155a3ba685a1bf8?lnk=3Dgst&q=3Dselect+a+specif=
ic+email+account+in+Entourage+%2B+Applescript&rnum=3D4&hl=3Den#c155a3ba685a=
1bf8

Here is the script thus far:
tell application "Microsoft Entourage"
activate
tell application "Microsoft Entourage"
set def to default mail account
if def =3D "Folders on My Computer" then
set account of window 1 to Exchange account "<User Name>"
end if
end tell
set mailFolders to {} as list
set mailFolders to Exchange account "<User Name>"
set thisFolder to choose from list mailFolders with prompt =AC
"Pick a mailbox to export" without multiple selections allowed

if ((count of messages of folder named thisFolder) =3D 0) then
display dialog "'" & (thisFolder as string) & =AC
"' contains no emails" buttons "OK" default button 1

Everything after the if ((count works fine. However when it runs the
script still selects the email in "Folders on My Computer" Rather then
the Exchange Account

TIA,

Mark

Re: Set Default Account in Entourage via Applescript by Diane

Diane
Thu Feb 15 16:55:31 CST 2007

On 2/15/07 6:52 AM, in article
1171551168.586659.313990@m58g2000cwm.googlegroups.com, "willmark@mac.com"
<willmark@mac.com> wrote:

> OK I have a fairly elaborate Apple script going for exporting emails
> from Entourage to a specific hard coded folder on my hard drive.
>
> The problem I am running into and cannot seem to solve is this: My
> script can only select the default folders of "Folders on My
> Computers" rather than the Exchange account that I have. All else in
> the rest of the scipt which is now quite lengthy, works exactly the
> way I want it to except this part. Can anyone shed light on what I am
> doing wrong?

Check out this script: AutoArchive Exchange Account to "On My Computer"

<http://www.entourage.mvps.org/exchange/autoarchive.html>
--
Diane Ross, Microsoft Mac MVP
Entourage Help Page
<http://www.entourage.mvps.org/>
One of the top five MS Entourage resources listed on the Entourage Blog.
<http://blogs.msdn.com/entourage/>



Re: Set Default Account in Entourage via Applescript by William

William
Thu Feb 15 22:36:34 CST 2007

In article <1171551168.586659.313990@m58g2000cwm.googlegroups.com>,
willmark@mac.com wrote:

> Here is the script thus far:
> tell application "Microsoft Entourage"
> activate
> tell application "Microsoft Entourage"
> set def to default mail account
> if def = "Folders on My Computer" then
> set account of window 1 to Exchange account "<User Name>"
> end if
> end tell
> set mailFolders to {} as list
> set mailFolders to Exchange account "<User Name>"
> set thisFolder to choose from list mailFolders with prompt ¬
> "Pick a mailbox to export" without multiple selections allowed
>
> if ((count of messages of folder named thisFolder) = 0) then
> display dialog "'" & (thisFolder as string) & ¬
> "' contains no emails" buttons "OK" default button 1
>
> Everything after the if ((count works fine. However when it runs the
> script still selects the email in "Folders on My Computer" Rather then
> the Exchange Account

Hi Mark!

Part of your problem may be that you're confusing the "Folders on My
Computer" folder for an account. The default account will be the bold
account listed when you view Tools --> Accounts. That's not the same
thing as the "Folders on My Computer" folder. Therefore, your first "if"
statement will always be false and your "def" variable will be empty. In
fact, you don't really need to specify the default account. Just specify
the Exchange account by name.

To get you started experiment with this:

tell application "Microsoft Entourage"
set theAccount to Exchange account "<account name as it appears in
Accounts>"
set mailFolders to name of folders of theAccount as list
end tell

You can then get different pieces of information about the contents of a
folder in your Exchange account, such as:

subject of every message of folder "Inbox" of theAccount as list
sender of every message of folder "Inbox" of theAccount as list
category of every message of folder "Inbox" of theAccount as list

or just

every message of folder "Inbox" of theAccount as list

Hope this helps! bill
--
William M. Smith
(Microsoft Interop MVP - Mac/Windows)

Re: Set Default Account in Entourage via Applescript by willmark

willmark
Fri Feb 16 13:12:34 CST 2007

On Feb 15, 11:36 pm, William Smith <meckli...@REM0VETH1S.comcast.net>
wrote:
> In article <1171551168.586659.313...@m58g2000cwm.googlegroups.com>,
>
>
>
> willm...@mac.com wrote:
> > Here is the script thus far:
> > tell application "Microsoft Entourage"
> > activate
> > tell application "Microsoft Entourage"
> > set def to default mail account
> > if def =3D "Folders on My Computer" then
> > set account of window 1 to Exchange account "<User N=
ame>"
> > end if

> > end tell
> > set mailFolders to {} as list
> > set mailFolders to Exchange account "<User Name>"
> > set thisFolder to choose from list mailFolders with prompt =AC
> > "Pick a mailbox to export" without multiple selections allow=
ed
>
> > if ((count of messages of folder named thisFolder) =3D 0) then
> > display dialog "'" & (thisFolder as string) & =AC
> > "' contains no emails" buttons "OK" default button 1
>
> > Everything after the if ((count works fine. However when it runs the
> > script still selects the email in "Folders on My Computer" Rather then
> > the Exchange Account
>
> Hi Mark!
>
> Part of your problem may be that you're confusing the "Folders on My
> Computer" folder for an account. The default account will be the bold
> account listed when you view Tools --> Accounts. That's not the same
> thing as the "Folders on My Computer" folder. Therefore, your first "if"
> statement will always be false and your "def" variable will be empty. In
> fact, you don't really need to specify the default account. Just specify
> the Exchange account by name.
>
> To get you started experiment with this:
>
> tell application "Microsoft Entourage"
> set theAccount to Exchange account "<account name as it appears in
> Accounts>"
> set mailFolders to name of folders of theAccount as list
> end tell
>
> You can then get different pieces of information about the contents of a
> folder in your Exchange account, such as:
>
> subject of every message of folder "Inbox" of theAccount as list
> sender of every message of folder "Inbox" of theAccount as list
> category of every message of folder "Inbox" of theAccount as list
>
> or just
>
> every message of folder "Inbox" of theAccount as list
>
> Hope this helps! bill
> --
> William M. Smith
> (Microsoft Interop MVP - Mac/Windows)

Thanks for the information, most helpful for pointing me in the right
direction.


Re: Set Default Account in Entourage via Applescript by willmark

willmark
Wed Feb 21 07:22:21 CST 2007

On Feb 16, 2:12 pm, willm...@mac.com wrote:
> On Feb 15, 11:36 pm, William Smith <meckli...@REM0VETH1S.comcast.net>
> wrote:
>
>
>
> > In article <1171551168.586659.313...@m58g2000cwm.googlegroups.com>,
>
> > willm...@mac.com wrote:
> > > Here is the script thus far:
> > > tell application "Microsoft Entourage"
> > > activate
> > > tell application "Microsoft Entourage"
> > > set def to default mail account
> > > if def =3D "Folders on My Computer" then
> > > set account of window 1 to Exchange account "<User=
Name>"
> > > end if
> > > end tell
> > > set mailFolders to {} as list
> > > set mailFolders to Exchange account "<User Name>"
> > > set thisFolder to choose from list mailFolders with prompt =AC
> > > "Pick a mailbox to export" without multiple selections all=
owed
>
> > > if ((count of messages of folder named thisFolder) =3D 0) then
> > > display dialog "'" & (thisFolder as string) & =AC
> > > "' contains no emails" buttons "OK" default button=
1
>
> > > Everything after the if ((count works fine. However when it runs the
> > > script still selects the email in "Folders on My Computer" Rather then
> > > the Exchange Account
>
> > Hi Mark!
>
> > Part of your problem may be that you're confusing the "Folders on My
> > Computer" folder for an account. The default account will be the bold
> > account listed when you view Tools --> Accounts. That's not the same
> > thing as the "Folders on My Computer" folder. Therefore, your first "if"
> > statement will always be false and your "def" variable will be empty. In
> > fact, you don't really need to specify the default account. Just specify
> > the Exchange account by name.
>
> > To get you started experiment with this:
>
> > tell application "Microsoft Entourage"
> > set theAccount to Exchange account "<account name as it appears in
> > Accounts>"
> > set mailFolders to name of folders of theAccount as list
> > end tell
>
> > You can then get different pieces of information about the contents of a
> > folder in your Exchange account, such as:
>
> > subject of every message of folder "Inbox" of theAccount as list
> > sender of every message of folder "Inbox" of theAccount as list
> > category of every message of folder "Inbox" of theAccount as list
>
> > or just
>
> > every message of folder "Inbox" of theAccount as list
>
> > Hope this helps! bill
> > --
> > William M. Smith
> > (Microsoft Interop MVP - Mac/Windows)
>
> Thanks for the information, most helpful for pointing me in the right
> direction.

<BUMP!>

OK so after some tinkering here is what I came up with:

tell application "Microsoft Entourage"
activate
tell application "Microsoft Entourage"
set theAccount to Exchange account id 2
set InBoxFolder to theAccount
end tell
end tell
set docFolder to (path to documents folder from user domain)
set fpath to (choose folder default location docFolder with prompt =AC
=AC
"Choose a folder in which to store your emails" without multiple
selections allowed) as string
--set fcount to 0
-- repeat with i in messages of folder named theAccount
set fcount to fcount + 1
set newFname to "" as string
set fname to (subject of i) as string
if ((count of characters of fname) > 30) then
set fname to ((characters 1 thru 25 of fname) & "...") as string
end if
if (fname contains ":") then
repeat with j in characters of fname
if (j as string =3D ":") then
set newFname to newFname & "-"
else
set newFname to newFname & j
end if
end repeat
set fname to newFname
end if

set fname to (fpath & fname) as string
tell application "Finder"
if (exists file (fname)) then
set k to 1
repeat while (exists file (fname & "-" & (k as string)))
set k to k + 1
end repeat
set fname to (fname & "-" & (k as string))
end if
end tell
save i in fname
tell application "Finder" to update file fname
tell application "Finder"
end tell


This part right here is perplexing me however:

set fcount to 0
repeat with i in messages of folder named theAccount

Every time I try to compile it is returns a syntax error of: "Expected
an end of line but found property or key form.

Again TIA
Mark