Welcome to the Office Mac Help Site About | Blog | Links | Glossary | Feedback | Downloads | Help

Custom Scripts
User requests

  1. Open message with defined character set
  2. 1000+ categories!
  3. Delete junk folder script for exchange account
  4. Finding path to misfiled messages
  5. Emptying IMAP Sent Items folder automatically
  6. Saving Groups
  7. Save Groups to Excel
  8. Export Selected Contacts
  9. Find messages missent to calendar and contacts

Save scripts as a compiled script & put it in the ‘Entourage Script Menu Items’ folder in your ‘Microsoft User Data’ folder. The scripts can be manually run from the menu. See Using Scripts for more help.

1) Simple script that will take an open message window (draft) and apply a defined character set (i.e. "Greek (ISO)").

First, open System Preferences, and then open Universal Access preferences. Make sure the checkbox to "Enable access for assistive devices" is checked, and then quit System Preferences and re-launch Entourage.

Copy this script into Script Editor:

tell application "System Events"
    tell process "Microsoft Entourage"
        pick menu item "Greek (ISO)" of menu 1 of menu item "Character Set" of menu "Format" of menu bar item "Format" of menu bar 1
        keystroke return using command down
    end tell
end tell

Then, save the script into ~/Documents/Microsoft User Data/Entourage Script Menu Items/. You can then run the script when you have a new message ready to send, and the script will apply the correct character set.


2) 1000+ categories!

I drag/drop 100 (pick a number) cards from Apple Address Book to the desktop, they save as vcard. Drag them into Entourage and - poof - 100 categories. Each card adds a category. How do I remove the added categories?

-- Remove Duplicate Categories
-- A script for Microsoft Entourage
-- Removes duplicate categories, without assigning items in the removed category 
--      to the original category of the same name
-- an Applescript by Barry Wainwright 
-- This script released under a Creative Commons Attribution, NonCommercial, ShareAlike 2.0 England & Wales License.
-- see http: /creativecommons.org/licenses/by-nc-sa/2.0/uk / for full details

tell application "Microsoft Entourage"
    set theCategories to categories
    repeat with x from 1 to count theCategories
        repeat with y from (count theCategories) to x + 1 by -1
            if name of item y of theCategories = name of item x of theCategories then
                delete (get item y of theCategories)
                set theCategories to items 1 thru (y - 1) of theCategories & items (y + 1) thru -1 of theCategories
            end if
        end repeat
    end repeat
end tell

3) Delete junk folder script for exchange account

I am looking for a way to modify the Delete Junk Folder script so as to work on the junk folder of an exchange account and not just the local folder (on My Computer). By Barry Wainwright.

Tell app "Microsoft Entourage"
Set theMessages to every message of folder "Junk E-Mail" of exchange account 1
Delete themessages
Delete themessages
End tell

4) Finding path to misfiled messages. This shows the path in a text window.

tell application "Microsoft Entourage"
    set theMessage to item 1 of (get current messages)
    set theItem to storage of theMessage
    set containerPath to {subject of theMessage, name of theItem}
    repeat
        try
            set theItem to parent of theItem
            copy name of theItem to end of containerPath
        on error
            exit repeat
        end try
    end repeat
    set AppleScript's text item delimiters to {"/"}
    set pathList to (reverse of containerPath) as text
    display dialog "Path to selected message is:" & return & pathList buttons {"OK"} default button 1
end tell

Download

Here is another version of this script. This will show the message in its own folder list, with the folder, wherever it is, highlighted in the Folders List at the left. By Paul Berkowitz.

tell application "Microsoft Entourage"
		 set theMessage to item 1 of (get current messages)
			set theItem to storage of theMessage
			set displayed feature of main window to theItem
					activate
	end tell
										

Download


5) Emptying IMAP Sent Items folder automatically

-- Delete Sent IMAP Mail v1.0
-- will delete mail sent more than 10 days ago from the sent mail folder of each IMAP account
-- an applescript by Barry Wainwright 
-- This script released under a Creative Commons Attribution, NonCommercial, ShareAlike 2.0 England & Wales License.
-- see http://creativecommons.org/licenses/by-nc-sa/2.0/uk/ for full details
tell application "Microsoft Entourage"
    try
        repeat with theAccount in every IMAP account
            set theFolder to IMAP sent items folder of theAccount
            set theMessages to (every message of theFolder whose time sent ¬
            delete theMessages
        end repeat
    end try
end tell

6) Saving Groups

The group entry is just plain text - open a group, select all and copy  to a text file. This script will do this for you – putting the contents of a selected group on the clipboard without having to open it:

-- Copy Group Entries to Clipboard v1.0
-- Barry Wainwright 22/04/2004
-- An applescript of Microsoft Entourage
-- This script will put all the entries of a selected group
-- on the clipboard as Tab-Delimited Text
-- Just select a group in the address book listing and run the script.

-- This script released under a Creative Commons Attribution, NonCommercial, ShareAlike 2.0 England & Wales License.
-- see http://creativecommons.org/licenses/by-nc-sa/2.0/uk/ for full details


tell application "Microsoft Entourage"
    try
        set theGroup to item 1 of (get selection)
    on error
        display dialog "Please select a group in the address book and run the script again" buttons {"OK"} default button 1 with icon stop
        return -99
    end try
    if class of theGroup is group then
        set exportList to {"Group: " & name of theGroup}
        set groupEntries to content of every group entry of theGroup
        repeat with anEntry in groupEntries
            copy {display name of anEntry & tab & address of anEntry} to end of exportList
        end repeat
        set {oldDelims, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
        set the clipboard to exportList as text
    else
        display dialog "Please select a group in the address book and run the script again" buttons {"OK"} default button 1 with icon stop
    end if
end tell 


7) Export a group's entries to an Excel spreadsheet

(Option: You can drag a group as txt file. Drag the txt file into Excel)


-- Export Group to Excel v1.0
-- export group entries from a selected Address Book Group to an excel spreadsheet
-- an applescript by Barry Wainwright mailto:barryw@mac.com
-- This script released under a Creative Commons Attribution, NonCommercial, ShareAlike 2.0 England & Wales License.
-- see http://creativecommons.org/licenses/by-nc-sa/2.0/uk/ for full details

tell application "Microsoft Entourage"
    set theBookRef to address book 1
    try
        set theNames to name of every group of theBookRef
    on error errMsg number errNum
        display dialog "No Groups Available for this Address Book" buttons {"Abort"} default button 1 giving up after 10
        return
    end try
    if (count theNames) > 1 then¬
        set theGroupName to item 1 of (get choose from list theNames¬ 
            with title¬ 
            "Group Selection" with prompt¬ 
            "Please choose the group to export" OK button name¬ 
            "Select" multiple selections allowed false¬ 
            without empty selection allowed)
        set theGroup to item 1 of (get every group of theBookRef whose name is theGroupName)
    else
        set theGroup to group 1 of theBookRef
    end if
    set theEntries to group entries of theGroup
    set resultList to {}
    repeat with anEntry in theEntries
        copy {display name of content of anEntry, address of content of anEntry} to end of resultList
    end repeat
    set entrycount to count theEntries
end tell

tell application "Microsoft Excel"
    activate
    make new workbook
    set the view of window 1 to normal view
    set the display page breaks of the active sheet to false
    set name of active sheet to name of theGroup
    set theRows to "1:" & entrycount
    set theRange to intersect range1 (range theRows of active sheet) range2 (range "a:b" of active sheet)
    set value of theRange to resultList
    autofit theRange
end tell


8) Export Selected Contacts

This script will export to an excel spreadsheet 'first name', 'last name' and 'default email address' (by Barry Wainwright)

tell application "Microsoft Entourage"
    try
        set theSelection to selection
        if class of item 1 of theSelection ≠ contact then error -128
    on error
        display dialog "Please select one or more contacts before running this script" buttons {"Abort"} default button 1
        return
    end try
    set exportList to {{"First Name", "Last Name", "Default Email Address"}}
    repeat with anItem in theSelection
        tell anItem
            copy {first name, last name, contents of default email address} to end of exportList
        end tell
    end repeat
end tell

tell application "Microsoft Excel"
    activate
    make new workbook
    set name of active sheet to "Exported Contacts"
    set theRange to get resize range "A1" row size (count exportList) column size (count item 1 of exportList)
    set value of theRange to exportList
    set the view of window 1 to normal view
    set the display page breaks of the active sheet to false
    autofit theRange
    autoformat theRange format range autoformat classic 3
end tell