As the Title states "Help with an Applescript for Outlook 2011 that moves all messages from a specific folder that match a source account to a different folder."
So, I have a "rule" that moves all new mail on my exchange account into a "Inbox" in a subfolder On My Computer. When I delete items form this subfolder inbox it goes into the "Deleted Items" On My Computer. I have made a sub-folder for "Deleted Items" in the same place as my "Inbox" sub-folder and I would like to run an Applescript on a schedule that can go into the main Deleted Items On My Computer and find the messages from that exchange account and move them into "subfolder/Deleted Items".
Googling about I cobbled the below together which will move ALL mail in Deleted Items:
tell application "Microsoft Outlook"
set topFolder to mail folder "AT&T" of on my computer
set destFolder to folder "Deleted Items" of topFolder
move every message of mail folder "Deleted Items" of on my computer to destFolder
end tell
The part I can't get past is now only selectively moving mail whose "account" is a specific value, like thus:
tell application "Microsoft Outlook"
set topFolder to mail folder "AT&T" of on my computer
set destFolder to folder "Deleted Items" of topFolder
move (every message of mail folder "Deleted Items" of on my computer whose account = "Att") to destFolder
end tell
the last addition of trying to filter by account kicks up the error
Microsoft Outlook got an error: Can’t make account into type specifier.
Any help appreciated!!
Devised a solution that works. Instead of a single line, selected all messages in the folder and looped through them, grabbing the account name as text and doing the compare and move.
tell application "Microsoft Outlook"
set topFolder to mail folder "AT&T" of on my computer
set destFolder to folder "Deleted Items" of topFolder
set srcFolder to mail folder "Deleted Items" of on my computer
set selectedMessages to messages of srcFolder
repeat with theMessages in selectedMessages
set thisAccount to account of theMessages
if (name of thisAccount as text is "Att") then
if (is read of theMessages is false) then
set theMessages's is read to true
end if
move theMessages to destFolder
end if
end repeat
end tell