An error that occurs one every second pass of a handler that saves emails in different mail boxes has me stumped.
It says all the numbers on the first call, then it say ‘2', then ‘loop’, then executes lines I don’t want it to execute, then says ‘3’, on the second call.
Repeats and rinses.
on transferMessage(theNewMailbox)
try
# set theCounter to theCounter + 1
# say "counter " & theCounter
set p to 1
set tempReDrawTheText to false
tell application "Finder"
if not (exists process "Mail") then tell application "Mail" to launch
end tell
set p to 2
tell application "Mail" to set thenewmailboxname to name of theNewMailbox as rich text
set p to 3
on error errmsg number errnum
if errnum = -1700 then
try
tell application "Mail" to set theNewMailbox to mailbox theNewMailbox
on error
return
end try
try
tell application "Mail" to set thenewmailboxname to name of theNewMailbox as rich text
end try
else
my displayError("Mail Manager's transferMessage in AppDelegate, start of handler, " & errmsg & " error number " & errnum & " p = " & p as text)
end if
end try
try
set p to 4
tell application "Mail"
if not (exists mailbox "* items to manually process") then
make new mailbox with properties {name:"* items to manually process"}
end if
end tell
on error errmsg number errnum
if errnum = -2763 then
try
if my runForOz then my displayError("Mail Manager's this is a mailbox error -2763 " & return & thenewmailboxname as text)
try
tell application "Mail" to set temp to (message id of my currentMailItem) as rich text
end try
end try
else
if my runForOz then my displayError("Mail Manager's MainProcessingLoops's first transferMessage " & errmsg & " number is " & errnum as text)
end if
end try
tell application "Mail"
try
set p to 5
if my currentMailItem ≠ {} then
set theOldMailbox to mailbox of my currentMailItem
else
my returnToRunningLoop()
end if
# if theOldMailbox is "* items to manually process" then my runningLoopCaller() # return
on error
set p to 6
my returnToRunningLoop()
end try
set p to 7
try
#
# Now actually shift the email
#
set p to 8
set theTempID to message id of my currentMailItem
set p to 9
set the mailbox of my currentMailItem to theNewMailbox
set my reDrawTheText to true
set my eMailHasBeenTransferred to true
# my insertEmailTextRewriteText()
set p to 10
set y to 0
set p to 12
say 1
repeat with xx from 1 to 40
try
say 2
tell current application to delay 0.1
say 3
if ((exists (some message whose message id is theTempID)) of theOldMailbox) then
try
say 4
delete ((some message whose message id is theTempID) of theOldMailbox)
say 4.1
end try
else
say 5
exit repeat
end if
end try
say 6
end repeat
say 7