-- Gets the date of the selected message -- https://discussions.apple.com/thread/6751836?start=0&tstart=0 -- This returns the date as "Day_of_the_Week, Full_Month Day, Year at Time AM/PM" -- Date Conversion added by RSH - 2016-02-02 set dateList to {} tell application "Mail" to if running then repeat with tMsg in (get selection) set end of dateList to the (date received of tMsg) as rich text end repeat set monthList to {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"} set numberList to {"1", "2", "3", "4", "5", "6", "7", "8", "9"} -- Separating Email Date for Reordering set dateString to item 1 of dateList set emailYear to word 4 of dateString set emailMonth to word 2 of dateString set emailDay to word 3 of dateString as string set emailTimeHours to word 6 of dateString set emailTimeMinutes to word 7 of dateString set emailTimeSeconds to word 8 of dateString set emailAMPM to word 9 of dateString -- Getting month value, added "as string" to fix single numbers to double digit (1->01) repeat with i from 1 to the count of monthList if item i of monthList is emailMonth then set monthPosition to i as string end repeat -- Concatenating "0" onto single digit numbers to make them double if numberList contains monthPosition then set monthPosition to "0" & monthPosition if numberList contains emailDay then set emailDay to "0" & emailDay -- Creating Reordered Date with Month Name -- set orderedDateString to emailYear & "-" & emailMonth & "-" & emailDay & " " & emailTimeHours & ":" & emailTimeMinutes " " & emailAMPM -- Creating Reordered Date with Month Value set orderedDateString to emailYear & "-" & monthPosition & "-" & emailDay & " " & emailTimeHours & ":" & emailTimeMinutes & " " & emailAMPM return orderedDateString end if