I used Eudora for over a decade, and it had a simple button to toggle editing on/off for received messages. (I miss all the power-user features still.) Microsoft Outlook can do this now.
Email is by definition insecure, and it makes no sense to be unable to edit out garbage (unless it is signed and sealed).
The script uses Spotlight to find the selected email and open it in BBEdit (change “BBEdit” to “TextWrangler” to use it instead).
Editing the raw source requires a bit of knowhow.
The most essential bits being:
A) The number that precedes all other text in the source. It signifies the number of characters between the beginning of the first header line and the beginning of the metadata-block at the end of the message. You have to correct that number to reflect your edit(s) for text to be displayed properly.
B) An edit won’t show up immediately after saving from BBEdit. You have to either: restart mail, rebuild the mailbox, or move the message to another mailbox and back which is close to what I do. I have a keyboard shortcut in Mail Act-On to COPY the selected message to my InBox. The copied message shows the edits, so I can check them out if needed and leave the original to await a restart of Mail.
** Yes it’s cumbersome, so I don’t routinely edit email anymore as I did in Eudora. However at some point I’ll write some filters in (probably) Perl to strip away some of the more obvious garbage from list-mail.
I activate the script with a FastScripts hotkey have been using it for some years now.
-------------------------------------------------------------------------------------------
# Auth: Christopher Stone <junksieve@thestoneforge.com>
# dCre: 2012-07-18 : 05:51
# dMod: 2013-06-25 : 14:26
# Appl: Mail & BBEdit
# Task: Open selected message's file in BBEdit for editing.
# Deps: Uses only OSX components.
# Test: Lion & Mountain Lion (might work in Snow Leopard but I cannot test).
# Tags: @Applescript, @Mail, @BBEdit, @Edit, @Message
-------------------------------------------------------------------------------------------
--» #### { NOTES } ########################################################################
-------------------------------------------------------------------------------------------
(*
TO-DO:
¢ Fix Spotlight Query.
+ Do 2nd query if 1st query fails.
*)
-------------------------------------------------------------------------------------------
--» HANDLERS
-------------------------------------------------------------------------------------------
on REPL(_str, _find, _repl)
set {oldTIDS, AppleScript's text item delimiters} to {AppleScript's text item delimiters, _find}
set _str to text items of _str
set AppleScript's text item delimiters to _repl
set _str to _str as text
set AppleScript's text item delimiters to oldTIDS
return _str
end REPL
-------------------------------------------------------------------------------------------
on textToBBEdit(_data)
if _data starts with "/" then
try
set _data to alias POSIX file _data
end try
end if
tell application "BBEdit"
activate
if class of _data = alias then
open _data
else if class of _data = text then
set newDoc to make new document with properties {text:_data}
end if
set bounds of front window to {303, 44, 1617, 1196}
end tell
end textToBBEdit
-------------------------------------------------------------------------------------------
--» MAIN
-------------------------------------------------------------------------------------------
try
set AppleScript's text item delimiters to {""}
tell application "Mail"
set _sel to selection
if length of _sel = 1 then
set _msg to item 1 of _sel
else
error "Too many messages selected."
end if
# Use account to find mail-folder in attempt to be compatible back to Snow Leopard.
set acnt1Dir to (account directory of account 1) as string
set {oldTIDS, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ":"}
set mailFldrLion to POSIX path of (text items 1 thru -3 of acnt1Dir as string)
set AppleScript's text item delimiters to oldTIDS
tell _msg
set mbxName to name of its mailbox
set mID to its id
set mSub to its subject
end tell
end tell
# Escape single quotes in subject for spotlight query string.
if mSub contains "'" then
set mSub to REPL(mSub, "'", "'\"'\"'")
end if
# Find email
set _cmd to "mdfind -onlyin " & mailFldrLion & " 'kMDItemDisplayName == \"" & mSub & "\"cd && kMDItemFSName == \"" & mID & ".emlx\"cd'"
--» ¢¢¢¢ Debug Code ¢¢¢¢
# textToBBEdit(_cmd)
# return
set emlFile to do shell script _cmd
if emlFile ≠"" then
textToBBEdit(emlFile)
else
error "No message was returned by Spotlight!"
end if
on error e number n
set e to e & return & return & "Num: " & n
tell me to set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
if button returned of dDlg = "Copy" then set the clipboard to e
end try
-------------------------------------------------------------------------------------------