------------------------------------------------------------------------------------------------
tell
application "Mail"
set msg
to item 1
of (get
selection)
tell msg
set
AppleScript's text item delimiters
to {linefeed &
linefeed}
set srcHdrs
to text item 1
of (get
source)
set
allHdrs to (get
all headers)
end tell
end
tell
# Part 1
set
dtHdrs
to (do shell script
"sed -En 's/^Date: *(.+)/\\1/p' <<< " &
quoted form
of (srcHdrs &
return &
allHdrs)
without altering line endings)
set
senderDate
to paragraph 1
of dtHdrs
set
localDate
to paragraph 2
of dtHdrs
set
localDate
to
do shell script
"date -jf \"%B %d, %Y %H:%M:%S\" " &
"\"" & localDate &
"\" \"+%a, %e %b %Y %H:%M:%S %z %Z\""
set
dList
to {"--------------------------------",
senderDate,
localDate,
"--------------------------------"}
choose from list
dList
with title "Date Strings from Mail"
with prompt ¬
"TOP: Sender" &
return &
"BOT: Local"
with
multiple selections allowed and
empty selection allowed
# Part 2
set
ipAdrs
to do shell script
"awk -F[ '/^Received:/ { print }' <<< " & (quoted form
of
allHdrs) &
" \\
| awk '/\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\]/ { print }' \\
| sed -En 's/.*\\[([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})
\\].*/\\1/gp' \\
| awk 'END{print}' "
tell
application "Safari"
activate
make new
document with properties {URL:_url}
end
tell
------------------------------------------------------------------------------------------------