Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

"Filter Mail Messages" in Automator doesn't filter out mails of today

Is it me, or does the Automator action "Filter Mail Messages" doesn't have an option to find messages that have not been sent or received today. It seems that there is no option to get rid of the messages sent or received today while filtering.


I mean there is no option for "Date received" -> "Not today"; and I seem to can not find any easy workaround for this.


i.e. What I'm trying to do is, filter the messages that are in a certain mailbox and are not sent or received in the last 7 days. However, the mails of today always show up.


I hope somebody had found a solution to this, it appears to be an obvious problem with the Automator, trying to work with the Mail App and many have probably run into this before.


Thanks!

MacBook Pro, Mac OS X (10.7.5), Mail App 5.3 (1283)

Posted on Apr 8, 2014 8:31 AM

Reply
Question marked as Best reply

Posted on Apr 8, 2014 3:43 PM

Hi Stultitia


I'm running Mail 7.3 and OSX 10.9.2, which are newer than the versions shown in your profile. But this works for me:


User uploaded file


It works just as well if I change 1 to 7.


If your workflow looks similar then your problem may have been fixed in more recent versions of the OS.


Rgds,


H

5 replies
Question marked as Best reply

Apr 8, 2014 3:43 PM in response to Stultitia

Hi Stultitia


I'm running Mail 7.3 and OSX 10.9.2, which are newer than the versions shown in your profile. But this works for me:


User uploaded file


It works just as well if I change 1 to 7.


If your workflow looks similar then your problem may have been fixed in more recent versions of the OS.


Rgds,


H

Apr 8, 2014 4:10 PM in response to HD

Thank you HD,


That is what I tried and that is the exact thing not working for me. It never includes today regardless of the day count I specify. I've tried "0" and "1" days as additional filters; but I'll try again.


Is this really specific to Lion I wonder, as you suggested?


I wish somebody using Lion gives me a hint.

Mar 18, 2015 10:57 AM in response to Stultitia

Ok, if you're still looking I found an applescript work around at http://stackoverflow.com/questions/1725690/applescript-to-archive-email-in-mail- app


Also, here's the applescript I'm using. I use automator to select the mailboxes I want to archive and to do the initial filtering.

Then I use the applescript to make sure I am not archiving email received in the last 24 hours.

Perhaps Apple will fix this some day, but for now ....

Maybe this will help someone 🙂



property secondsIn21Days : 1814400


on run {input, parameters}


try


set dateToday to current date



--

tell application "Mail"

set archiveCount to 0

set theArchiveMailboxName to "CurrentArchive"

if (mailboxtheArchiveMailboxNameexists) = false then

makenewmailboxwith properties {name:theArchiveMailboxName}

end if


repeat with aMessage in input

-- set theMessages to input

-- repeat with aMessage in theMessages

set messageDate to date received of aMessage

set timeDifference to dateToday - messageDate

if timeDifferencesecondsIn21Days then

moveaMessagetomailboxtheArchiveMailboxName

set archiveCount to archiveCount + 1

end if

end repeat

end tell


display notification "emails archived = " & archiveCountwith title "Mail Archive"


-- return -- Successful completion of handler.

on error errStrnumbererrorNumber


-- If our own error number, warn about bad data.


-- if the errorNumber is equal to 750 then


-- display dialog "All items in the list must be integers."


-- return integerSum -- Return the default value (0).


-- else


-- An unknown error occurred. Resignal, so the caller


-- can handle it, or AppleScript can display the number.

error errStrnumbererrorNumber


display notification "emails archived = " & archiveCountwith title "Mail Archive"


-- end if

end try

end run

Mar 18, 2015 7:20 PM in response to FranklyPhoney

OK.... Did a bit more debugging... updated script

property secondsIn21Days : 1814400


on run {input, parameters}


try


set dateToday to current date



--

tell application "Mail"

set archiveCount to 0

set theArchiveMailboxName to "CurrentArchive"

if (mailboxtheArchiveMailboxNameexists) = false then


makenewmailboxwith properties {name:theArchiveMailboxName}

end if


repeat with aMessage in input


-- set theMessages to input


-- repeat with aMessage in theMessages

set messageRDate to date received of aMessage

set messageSDate to date sent of aMessage

set messageSubject to subject of aMessage

set messageID to id of aMessage

set timeRDifference to 0

set timeSDifference to 0


-- if messageRDate > 0 then

set timeRDifference to dateToday - messageRDate


-- end if


-- if messageSDate > 0 then

set timeSDifference to dateToday - messageSDate


-- end if


display dialogmessageSubject & " " & messageID & " " & timeRDifference & " " & timeSDifference

if timeRDifference > secondsIn21Days then


display dialog "Move " & messageID & " Received" & messageRDate & " " & messageSDate


moveaMessagetomailboxtheArchiveMailboxName

set archiveCount to archiveCount + 1

else if timeSDifference > secondsIn21Days then


display dialog "Move " & messageID & " Sent" & messageRDate & " " & messageSDate


moveaMessagetomailboxtheArchiveMailboxName

set archiveCount to archiveCount + 1


end if

end repeat

end tell


display notification "emails archived = " & archiveCountwith title "Mail Archive"


-- return -- Successful completion of handler.

on error errStrnumbererrorNumber


-- If our own error number, warn about bad data.


-- if the errorNumber is equal to 750 then


-- display dialog "All items in the list must be integers."


-- return integerSum -- Return the default value (0).


-- else


-- An unknown error occurred. Resignal, so the caller


-- can handle it, or AppleScript can display the number.

error errStrnumbererrorNumber


display notification "emails archived = " & archiveCountwith title "Mail Archive"


-- end if

end try

end run

"Filter Mail Messages" in Automator doesn't filter out mails of today

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.