This information is for TaskPaper 2 which is old and outdated. TaskPaper 3 is the current version of TaskPaper. For TaskPaper 3 support please visit the support forums.
This is a modification of the "Add Current Mail to TaskPaper" script. This script takes the currently selected message in Mail to create a TaskPaper task in the Inbox project. (Note assumes that you have a project named "Inbox".) The new task name is the Mail message subject. The script then goes on to create a note under the newly created task. The note contains a link to the message as the first item and then contains a 3 sentence summary of the body of the message.
tell application "Mail"
try
set theSelection to the selection
if the length of theSelection is less than 1 then error "One or more messages must be selected."
repeat with theMessage in theSelection
my importMessage(theMessage)
end repeat
end try
end tell
on importMessage(theMessage)
set theBody to ""
set theDate to ""
set messageURL to ""
set theSubject to ""
try
tell application "Mail"
set theSubject to subject of theMessage
set theDate to date received of theMessage
set messageURL to "message://%3C" & (message id of theMessage) & "%3E"
set theBody to summarize (content of theMessage as string) in 3 as text
end tell
set cleanBody to SearchReplace(theBody, (ASCII character 10), " ")
tell application "TaskPaper"
tell front document
tell project named "Inbox"
make new entry with properties {name:theSubject, entry type:task type}
tell task named theSubject
make new entry with properties {name:messageURL & " " & cleanBody, entry type:note type}
end tell
end tell
end tell
end tell
tell application "Growl"
set the allNotificationsList to ¬
{"Mail to TaskPaper success"}
set the enabledNotificationsList to ¬
{"Mail to TaskPaper success"}
register as application ¬
"Mail to TaskPaper" all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
icon of application "TaskPaper"
notify with name ¬
"Mail to TaskPaper success" title ¬
"Added to TaskPaper" description ¬
theSubject application name "Mail to TaskPaper"
end tell
on error theError
display dialog theError
end try
end importMessage
on SearchReplace(sourceStr, searchString, replaceString)
-- replace <searchString> with <replaceString> in <sourceStr>
set searchStr to (searchString as text)
set replaceStr to (replaceString as text)
set sourceStr to (sourceStr as text)
set saveDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to (searchString)
set theList to (every text item of sourceStr)
set AppleScript's text item delimiters to (replaceString)
set theString to theList as string
set AppleScript's text item delimiters to saveDelims
return theString
end SearchReplace