Hi, peoples
There is a script that must delete messages whose is in spam list, when message arrived.
property spamList : {"gs@britishdesign.ru", "gs=britishdesign.ru@mail70.wdc01.mcdlv.net", "analytic.center@advgroup.ru", "analytic.center@advglobal.com", "internal.communications@advglobal.com", "info@britishdesign.ru"}
on run
my checkEmail()
return
end run
on checkEmail()
tell application "Microsoft Outlook"
-- activate
-- get the currently selected message or messages
set selectedMessages to messages of inbox
repeat with theMessage in selectedMessages
if is read of theMessage is false then
-- get the information from the message, and store it in variables
set theName to subject of theMessage
set theCategory to category of theMessage
set theContent to content of theMessage
set messageSender to sender of theMessage
-- Get the account for the message
set messageAccount to account of theMessage
set messageAdress to address of messageSender
set messageName to name of messageSender
if ((messageSender is not missing value) and (messageAdress is in spamList)) then
set is read of theMessage to true
delete theMessage
end if
end if
end repeat
end tell
return
end checkEmail
If i try to start it outside Outlook all work well, the Message has been marked as read and move in to the trash.
When script start inside Outlook with rules “ “When a new message arrive” “ message move in to the trash, but don’t set “as read”.
And Outlook show on icon number of unread messages count.
Whats wrong?