AppleScript with Exchange Public Folders

J

Jeff Zienowicz

I'd like to modify the very useful scripts for copying contact categories
to/from Custom Field 8 (found at http://www.cortig.net/wordpress/?p=73) so
they'll work with an address book which is an Exchange public folder. I've
tried a number of syntax variations to try to accomplish this, but am so far
unsuccessful.

I have a public address book called "Contacts" in the "All Public Folders"
folder. It is also copied to the Favorites folder. I have full rights to
the folder. This code throws an "Access Not Allowed" error:

tell application "Microsoft Entourage"
-- added this line:
set MyBook to address book "Contacts" in folder "Contacts" in public
folder of Exchange account
-- modified this line:
set MyContacts to every contact in MyBook
set AppleScript's text item delimiters to {";"}
repeat with OneContact in MyContacts

[etc.]

I've tried every other syntax I can think of, most of which result in "Can't
get folder" errors.

Is this possible to do -- modify a public address book's contents with
AppleScript?

thanks,
Jeff
 
C

Corentin Cras-Méneur

Jeff Zienowicz said:
I've tried every other syntax I can think of, most of which result in "Can't
get folder" errors.

Is this possible to do -- modify a public address book's contents with
AppleScript?


I'm not sure it could be so easy. The scripts you used were designed to
use the default address book in ENtourage (and that's why they can
easily be accesssed). You cannot set the public AB as default and after
looking at the AppleScript ENtourage dictionaries for a while I couldn't
find any goot option to do so. Hopefully someone with much better
knowledge in AppleScript will offer an option (Paul?? Allen?? ).

Corentin
 
A

Andy Ruff

If the calendar is in your favorites, you can access it through a script
such as:

tell application "Microsoft Entourage"

return favorites folder of Exchange account 1

end tell

-Andy

Andy Ruff
MacBU Program Management
Entourage Weblog: http://blogs.msdn.com/entourage/

This posting is provided ³AS IS² with no warranties, and confers no rights.



I'd like to modify the very useful scripts for copying contact categories
to/from Custom Field 8 (found at http://www.cortig.net/wordpress/?p=73) so
they'll work with an address book which is an Exchange public folder. I've
tried a number of syntax variations to try to accomplish this, but am so far
unsuccessful.

I have a public address book called "Contacts" in the "All Public Folders"
folder. It is also copied to the Favorites folder. I have full rights to
the folder. This code throws an "Access Not Allowed" error:

tell application "Microsoft Entourage"
-- added this line:
set MyBook to address book "Contacts" in folder "Contacts" in public
folder of Exchange account
-- modified this line:
set MyContacts to every contact in MyBook
set AppleScript's text item delimiters to {";"}
repeat with OneContact in MyContacts

[etc.]

I've tried every other syntax I can think of, most of which result in "Can't
get folder" errors.

Is this possible to do -- modify a public address book's contents with
AppleScript?

thanks,
Jeff

--
Andy Ruff
MacBU Program Management
Entourage Weblog: http://blogs.msdn.com/entourage/

This posting is provided ³AS IS² with no warranties, and confers no rights.
 
C

Corentin Cras-Méneur

Andy Ruff said:
If the calendar is in your favorites, you can access it through a script
such as:

tell application "Microsoft Entourage"

return favorites folder of Exchange account 1

end tell

-Andy

Thanks a lot for the tip Andy,

Corentin
 
J

Jeff Zienowicz

Thanks a lot for the tip Andy,

Corentin

Thanks Andy and Corentin for your responses. I'll play around with it when
I get a little time and report back if I'm able to make it work. I think it
might come in handy for other Exchange users who want to (1) backup
categories assigned to public address books and (2) effectively share the
categories across machines: use one machine to assign the categories and run
the script to copy to custom field 8; all other machines run the Copy From
Field 8 script to assign the categories.

Jeff
 
J

Jeff Zienowicz

Thanks Andy and Corentin for your responses. I'll play around with it when
I get a little time and report back if I'm able to make it work. I think it
might come in handy for other Exchange users who want to (1) backup
categories assigned to public address books and (2) effectively share the
categories across machines: use one machine to assign the categories and run
the script to copy to custom field 8; all other machines run the Copy From
Field 8 script to assign the categories.

Jeff

Thought I'd report in with a status of "No Luck So Far." Although I can
certainly get the ID of the Exchange Favorites, I can't seem to access its
contents. For example, if, inside of my Tell Block, I put:

set x to favorites folder of Exchange account 1
count x

it returns 0. I can't seem to iterate over the items in that folder (which
of course are probably more akin to aliases as they point to the folders I
actually want to manipulate).

I've been through the entire Entourage AppleScript dictionary and tried
every syntax variation I can think of, though I am by no means an
AppleScript expert. I've also struck out on Google.

If anyone does turn up a way to work with an Exchange public address book
via AppleScript per my original post, I'd be eternally grateful.

Jeff
 
P

Paul Berkowitz

Thought I'd report in with a status of "No Luck So Far." Although I can
certainly get the ID of the Exchange Favorites, I can't seem to access its
contents. For example, if, inside of my Tell Block, I put:

set x to favorites folder of Exchange account 1
count x

it returns 0. I can't seem to iterate over the items in that folder (which
of course are probably more akin to aliases as they point to the folders I
actually want to manipulate).

I've been through the entire Entourage AppleScript dictionary and tried
every syntax variation I can think of, though I am by no means an
AppleScript expert. I've also struck out on Google.

If anyone does turn up a way to work with an Exchange public address book
via AppleScript per my original post, I'd be eternally grateful.

Jeff

Why "cont"? what are you looking for? Just the _number_ of favorites you
have?? (Why?)

If you want to get the name of every favorites folder:

tell application "Microsoft Entourage"
set x to favorites folder of Exchange account 1
return (name of every folder of x)
end tell


Or do you want something other than the name? The IDs?

return (ID of every folder of x)

The actual folders?

return (every folder of x)

(returns folders by ID, as it happens).

If you need the full paths, it's a lot more complicated.

--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.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 Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
J

Jeff Zienowicz

Why "cont"? what are you looking for? Just the _number_ of favorites you
have?? (Why?)

I was using Count as an example. I was trying, per a suggestion from Andy
Ruff, to use the Favorites as a way to access a public address book for an
Exchange account via the AppleScript API: I want to modify records in a
public contacts folder/address book via AppleScript.
If you want to get the name of every favorites folder:

tell application "Microsoft Entourage"
set x to favorites folder of Exchange account 1
return (name of every folder of x)
end tell

I have two items in Favorites -- a public address book called Contacts, and
a mail folder called General. The above code returns only "General." It
seems to not see "Contacts".
Or do you want something other than the name? The IDs?

return (ID of every folder of x)

The actual folders?

return (every folder of x)

(returns folders by ID, as it happens).

In each of these cases, AppleScript seems to see the mail folder but not the
address book. Again, this project really has nothing to do with Favorites
if there's another way to access the public folder. I want to do two things
with a public address book: (1) Open a contact record (given its ID) from
another application, and (2) back up category information for all records in
the address book by setting the value of one of the custom fields to the
category(ies) of each record (ideally re-using the existing scripts that do
this for local address books).

Thanks,
Jeff
 
P

Paul Berkowitz

In each of these cases, AppleScript seems to see the mail folder but not the
address book. Again, this project really has nothing to do with Favorites
if there's another way to access the public folder. I want to do two things
with a public address book: (1) Open a contact record (given its ID) from
another application, and (2) back up category information for all records in
the address book by setting the value of one of the custom fields to the
category(ies) of each record (ideally re-using the existing scripts that do
this for local address books).

I can't verify this, since there are no public folder address books nor have
I permissions to make new pubic folders on my test Exchange account. But I
believe you. It looks as if public folder address books and calendars as
"favorites" may have been an afterthought that didn't make it into the
AppleScript access of Exchange accounts.

You might as well try removing it from Favorites then adding it again, if
you can. If that doesn't work you won't be able to access it via
AppleScript. Your comment may be seen here, but I suggest reporting it as a
bug via Help/Send Feedback.

--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.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 Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
J

Jeff Zienowicz

You might as well try removing it from Favorites then adding it again, if
you can. If that doesn't work you won't be able to access it via
AppleScript. Your comment may be seen here, but I suggest reporting it as a
bug via Help/Send Feedback.

No go. My additional testing supports your theory that if the public folder
is an address book rather than a mail folder, it's ignored by AppleScript.

If indeed Favorites was the only possible way to do this, then it seems
there is no way to access or manipulate a public address book from a script
-- although I'm a little surprised that this hasn't been discovered before.

I guess I'll notify my client that it is not currently possible to access
public folder address book records via AppleScript, and we'll scrub the
project.

Thanks to Paul and Andy for suggestions; I wish this could have worked, as
it would have proven very useful.

- Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top