To use, you first need to turn X-POPFile-Link Header to On in the Configuration area of Popfile. Then install the below script into your ~Library/Scripts/Mail folder.
using terms from application "Mail"
on perform mail action with messages incomingMessages
set logString to "" & return
tell application "Mail"
repeat with msg in incomingMessages
set popFileLink to (content of header ¬
"x-popfile-link" of msg)
set popFileLink to (characters 2 through ¬
((count of popFileLink) - 1) of popFileLink)
log "PopFile: " & popFileLink
tell application "Safari" to open location ¬
(popFileLink as string)
end repeat
end tell
end perform mail action with messages
on run
tell application "Mail" to set sel to selection
tell me to perform mail action with messages sel
end run
end using terms from
[robg adds: I haven't tested this one...]

