Monday, March 1, 2021

#1 2021-02-21 05:36:10 pm

wygde3
Member
Registered: 2019-12-14
Posts: 3

Count in Mailbox Wrong?

As part of a bigger script I have found that the count in Applescript for the number of messages in a mailbox does not coincide with what I see in the mailbox directly. I discovered this when I was looping through the messages and when there was only one it was going around 4 times.

To try and pin this down I created a mailbox called Counter 1 and put a number of emails in it (28 to be precise). When I look at the count at the top of the window in Mail it says 28. When I count the messages it says 28. When I run the following script it says 36!

Applescript:



tell application "Mail"
   
   set currentMessageCount to 0
   
   set Counter1Location to mailbox "Counter 1" of account "myaccount"
   
   set currentMessageCount1 to the (count of messages of Counter1Location)
   
   display dialog "Counter 1 has " & currentMessageCount1 & " messages" as string
       
end tell

So the question is why does it show a different number as it ruins any script trying to deal with the 28 messages as the loop goes round 36 times. Some of the messages seem to be being dealt with more than once.

(The only other information that I can offer at the moment is that the main script does move messages around by using 'set mailbox'.)

Any help as to why this might be happening and how to sort it gratefully accepted by this newbie AppleScripter!

Model: MacBook Pro (Retina, Mid 2012)
AppleScript: 2.7
Browser: Safari 537.36
Operating System: macOS 10.14

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)