Title: Re: Print Links
On 12/20/00 2:28 PM, "Jeff Friedman" <[EMAIL PROTECTED]> wrote:

> How can I PRINT a list of all the linked TASKS for a given CONTACT?
>
> Thanks,
>
> Jeff
>
With this script: There are a few workarounds for the several limitations in Entourage's scripting at the moment (whose clauses for links of tasks not implemented, can't print from a note).

First - you have to create links from each task to any contact it relates to. Then select the contact in the Address Book and run the script.

You have two alternatives for printing: the way it's set now, it will open a new note with a list of each task  linked to that contact, each task "name" followed by its Due Date and "[completed]" if it is. Then you print it out manually, and either close or delete the note as you like.

Alternatively, if you want it to print automatically, it can print it out in the form of a "message" which you won't ever see. You can make a note or not as you like. Follow the directions near the bottom of the script.


-------------------------------TASK LIST FOR CONTACT ---------------------

tell application "Microsoft Entourage"
    
    try
        set theSelection to the selection
        set theContact to item 1 of theSelection
        if class of theContact � contact or length of theSelection � 1 then error number -128
    on error
        beep 2
        display dialog "! You must select one contact in the Address Book fro this script to work." buttons {"OK"} default button "OK" with icon 0
        return
    end try
    
    set contactName to name of theContact
    set theTasks to every task
    
    set taskNames to {}
    repeat with theTask in theTasks
        if links of theTask contains {theContact} then
            tell AppleScript to set d to due date of theTask
            try
                set dueDate to the clock from d using system form "%d" -- with Akua Sweets
            on error
                try --OS 9
                    set dueDate to (text 1 thru 3 of ("" & month of d)) & " " & day of d & ", " & year or d
                on error
                    set theDate to date string of d
                    set theDate to text (word 2 of theDate) thru -1 of theDate
                end try
            end try
            set ifCompleted to completed of theTask
            if ifCompleted then
                set ifCompleted to "  [completed]"
            else
                set ifCompleted to ""
            end if
            set end of taskNames to (name of theTask & " / Due Date: " & dueDate) & ifCompleted
        end if
    end repeat
    
    if taskNames � {} then
        
        set {ods, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {return}}
        set theContent to "" & taskNames
        set AppleScript's text item delimiters to ods
        try
            set theDate to the clock using system form "%d" -- with Akua Sweets
        on error
            try --OS 9
                set cd to (current date)
                set theDate to (text 1 thru 3 of ("" & month of cd)) & " " & day of cd & ", " & year or cd
            on error
                set theDate to date string of (current date)
                set theDate to text (word 2 of theDate) thru -1 of theDate
            end try
        end try
        set theSubject to "Tasks re " & contactName & " as of " & theDate
        set theContent to theContent
        set myName to name of me contact
        
        -- remove dashes from next next  four lines if you want to print automatically from  a "message"
        --set theDraft to make new outgoing message at drafts folder with properties {subject:theSubject, content:theContent, recipient:{address:{display name:myName, address:""}}}
        --print theDraft    
        --delete theDraft
        --delete theDraft
        
        --put double-dashes before, or remove completely, the next two lines if you print from message and don't want a note
        set theNote to make new note with properties {name:theSubject, content:theContent}
        open theNote
        
    else
        display dialog "There are no tasks pertaining to " & contactName & "."  buttons {"OK"} default button "OK" with icon 2
    end if
    
end tell

-----------------end script------------------------------------
--
Paul Berkowitz

Reply via email to