Applescript for unread mail
Greetings,
A long time ago, I created the following script that I run occasionally, which makes me a cvs file of the sender subject and date of unread messages in a specific mailbox. Been working fine for a couple of years. Of late it is giving me ALL of the messages in the mailbox, rather than just the unread messages. Any idea what might be happening here?
tell application "Mail"
set myAccount to account "Andrew.cmu.edu"
set myMailbox to mailbox "INBOX/@Action/PMW Blog" of myAccount
set myCount to count of messages in myMailbox
set clipboardText to ""
repeat with i from 1 to myCount - 1
set thisMsg to messagei of myMailbox
set f to extract name fromsender of thisMsg
set ff to quoted form of f
set d to date sent of thisMsg
set d to (month of d as integer) & "/" & day of d & "/" & year of d
set s to subject of thisMsg
set ss to RemoveFromString(s, ",") of me
set s to quoted form of ss
if read status of thisMsg is false then
set clipboardText to clipboardText & ff & ", " & s & ", " & d & return
end if
end repeat
do shell script "echo " & clipboardText & " >> ~/Desktop/headers.csv"
do shell script "open ~/Desktop/headers.csv"
--delay 10
--do shell script "rm ~/Desktop/headers.csv"
end tell
--return clipboardText
on RemoveFromString(theText, CharOrString)
local ASTID, theText, CharOrString, lst
set ASTID to AppleScript'stext item delimiters
try
--considering caseif theText does not contain CharOrString then ¬
return theText
set AppleScript'stext item delimiters to CharOrString
set lst to theText'stext items
--end consideringset AppleScript'stext item delimiters to ASTID
return lst as text
on error eMsgnumbereNum
set AppleScript'stext item delimiters to ASTID
error "Can't RemoveFromString: " & eMsgnumbereNum
end try
end RemoveFromString
iMac (27-inch, Late 2013), OS X Mavericks (10.9.5)