On Mar 03, 2012, at 10:51, Mel Charters wrote:
Does anyone know whether it is possible to detect Mail messages that contain HTML with web beacons embedded using AppleScript?
______________________________________________________________________
on perform_mail_action(info)
try
tell application "Mail"
set selectedMessages to |SelectedMessages| of info
set theRule to |Rule| of info
repeat with theMessage in selectedMessages
set theSource to source of theMessage
set theRuleName to name of theRule
set theText to "The rule named '" & theRuleName & "' matched this message:" & return & return & "Source: " & return & return & theSource
tell application "BBEdit"
activate
tell text of front text window
set after it to theSource & return
select insertion point after last character
end tell
end tell
end repeat
end tell
on error eMsg number eNum
set {c, s} to {return, "------------------------------------------"}
set e to s & c & "Error: " & eMsg & c & s & c & "Error Number: " & eNum & c & s
beep
tell me to display dialog e
end try
end perform_mail_action
TextWrangler should work if you don't have BBEdit.
You then need to be able to parse the source for web-bugs.
I would use the
Satimage.osax's 'find text' with regular expressions to do the parsing, but you could easily shell-out to Perl, Python, Ruby, etc.