osx - Applescript to delete message in a category in Outlook 2011 -
osx - Applescript to delete message in a category in Outlook 2011 -
context
in outlook 2011, have rule automatically sets category incoming mail service - "purple category". email category automatically deleted after 1 week.
i utilize applescript select mail service in inbox in "purple category" , older 1 week , move them deleted folder.
issuethe problem not able select messages in violet category applescript. description of outlook dictionary seems message , category @ same level:
below description of both item in outlook dictionary:
category n, pl categories [inh. object > item] : category.
contained application.
message n [inh. todoable object > categorizable object > object > item; see debug suite] : e-mail message.
contains recipients, recipients, cc recipients, bcc recipients, attachments;
contained application, mail service folders.
as can see both contained application in applescript when try:
set messagestodelete message in inbox {category "purple category"}
i error message saying:
can’t message of inbox of application "microsoft outlook" {category "purple category"}. access not allowed.
the rest of code:
set daystopreserve 7 set datereference (current date) - (daystopreserve * days) tell application "microsoft outlook" set messagestodelete message in inbox {category "purple category"} , time received ≤ datereference if messagestodelete {} homecoming end if permanently delete messagestodelete end tell display dialog (count messagestodelete) & " old mail service messages have been purged" text buttons ["ok"]
you have loop through messages have categories
tell application "microsoft outlook" repeat afolder in mail service folders set themsgs (every message of afolder it's category not {}) -- loop through messages repeat amsg in themsgs -- categories of message set cats categories of amsg -- loop through categories repeat acat in cats set catname name of acat -- check see if category of emails want delete if catname "purple category" time received of amsg set foo date of time received of amsg -- compare dates , delete amsg -- exit loop don't error after deleting message exit repeat end if end repeat end repeat end repeat end tell
osx outlook applescript
Comments
Post a Comment