• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Apple Mail Date Remote & Local and IP Lookup
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Apple Mail Date Remote & Local and IP Lookup


  • Subject: Apple Mail Date Remote & Local and IP Lookup
  • From: Christopher Stone <email@hidden>
  • Date: Fri, 21 Sep 2012 13:51:37 -0500

Hey Folks,

Just messing around here.

I have a script to display the Unix date/time of a message, and I expanded this to show both the local and remote dates.

I also am fiddling around with an IP lookup of the sender.

Parts 1 & 2 are independent of each other but dependent upon the previous code.

Question:

Does anyone know of a better IP lookup service?

Thanks.

--
Chris

------------------------------------------------------------------------------------------------
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}' "

set _url to "http://www.botsvsbrowsers.com/ip/" & ipAdrs & "/index.html"

tell application "Safari"
  activate
  make new document with properties {URL:_url}
end tell
------------------------------------------------------------------------------------------------

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Apple Mail Date Remote & Local and IP Lookup
      • From: Lists <email@hidden>
  • Prev by Date: Re: Scripting Contacts in Mountain Lion
  • Next by Date: Re: Apple Mail Date Remote & Local and IP Lookup
  • Previous by thread: Re: Mail Rules and 10.8.2
  • Next by thread: Re: Apple Mail Date Remote & Local and IP Lookup
  • Index(es):
    • Date
    • Thread