FWIW,

I have been mulling and playing with the combined scripts by Andy Fragen,
Marlyse, cheshirekat and others both on and off the list, and came up
with the script below to help handle followups to emails received in
PowerMail. I hadn't really thought about handling it with Applescript
until Marlyse brought it up, and afterwards I couldn't put it down.

The script is highly customizable for different tastes. If you use a
standard number of days to follow up change the property defaultDays to
reflect that, and just hit return when prompted to enter how long.

Another feature I added was adding the subject to the URL handed to iCal.
I found myself forgetting which mail I was following up on after 3, 7,
20+ days. Now the current subject will be carried forward with a "Follow
Up" prepended.

Again, it's probably one of 1000s of possibilities, but I thought someone
else might like it. Feel free to share it.

Kename

<description>
Pieces of this script are from Andy Fragen, chesirekat, and Marlyse
[PowerMail Discussion List], URL encoding is from Name: Jonathan Nathan
Homepage: http://homepage.mac.com/jonn8/as/

The above script will act on the message selected, or list of messages
selected in the Mail Browser window. You will get two dialogs; One
prompting you to choose a calendar from a list of your editable
calendars, the second prompts you to enter how many days until the
message is due. The ToDo summary will include the text in the property
reply Prompt, the name of the sender of the message and the original
subject of the message. The URL in iCal will also include a modified
subject line for a message generated from the ToDo. The text of the
properties can be modified to; include a different message, scale or
extend the list of due date numbers. Modify or fix the script as you
will, if it doesn't work as you want.
</description>

<applescript>
property allowed_URL_chars : (characters of "$-_.+!
*'(),1234567890abcdefghijklmnopqrstuvwxyz")
property hex_list : (characters of "0123456789ABCDEF")
property msgPrompt : "Which Calendar do you want to create the ToDo in?"
property replyPrompt : "Reply by email to: " & return
property mySubject : "[Follow Up]:"
property defaultDays : "7"

to getCalendarChoice()
        tell application "iCal"
                activate
                set the writableCalendars to the title of calendars whose 
writable is true
                try
                        set the listChoice to item 1 of (choose from list 
writableCalendars
with prompt msgPrompt OK button name "This One" without multiple
selections allowed and empty selection allowed)
                on error
                        beep
                        return false
                end try
        end tell
        return the listChoice
end getCalendarChoice

to encode_URL_string(this_item)
        set character_list to (characters of this_item)
        repeat with i from 1 to number of items in character_list
                set this_char to item i of character_list
                if this_char is not in allowed_URL_chars then set item i of
character_list to my encode_URL_char(this_char)
        end repeat
        return character_list as string
end encode_URL_string

to encode_URL_char(this_char)
        set ASCII_num to (ASCII number this_char)
        return ("%" & (item ((ASCII_num div 16) + 1) of hex_list) & (item
((ASCII_num mod 16) + 1) of hex_list)) as string
end encode_URL_char

to makeAToDo(calPick, replyDue, sURL, replySum)
        tell application "iCal"
                activate
                set the calVar to the first calendar whose title is the calPick
                set theToDo to (make new todo at the end of the todos of the 
calVar
with properties {due date:replyDue, summary:replySum, url:"mailto:"; & sURL})
                activate theToDo
                show theToDo
        end tell
end makeAToDo

tell application "PowerMail 5.0.1b1 4304"
        set the msgList to the current messages
        repeat with targetMsg in the msgList
                set the msgSubject to the subject of the targetMsg
                set the targetMsgSender to the sender of the targetMsg
                set the msgSenderName to the display name of the targetMsgSender
                set the sURL to the email address of the targetMsgSender & 
"?Subject="
& my encode_URL_string(mySubject & msgSubject)
                set the replySum to the replyPrompt & the msgSenderName & 
return & the
msgSubject
                set calendarPick to my getCalendarChoice()
                if not (calendarPick is false) then
                        activate
                        set the numberGiven to text returned of (display dialog 
"How many days
until reply?" default answer defaultDays buttons {"Cancel", "OK"} default
button 2) as integer
                        set the replyDueDate to (the (current date) + 
(numberGiven * days))
                        my makeAToDo(calendarPick, replyDueDate, sURL, replySum)
                end if
        end repeat
end tell

</applescript>


Reply via email to