Thank you very, very much Yvan.
You made me look deeper into the problem, and I realized you had probably nominated a mailbox which was not nested, whereas MY mailbox was nested three deep.
Turns out the command refuses to work with nested mailboxes, where the manual import handles them fine.
AND, an added bonus, empty mailboxers are ignored.
It seems to queue the imports up, but it would be nice if there were some way of waiting for each import. This fails.
property cccDisk : ""
my nowCopyInformation()
on nowCopyInformation()
try
tell application "Finder"
set (my cccDisk) to startup disk
activate
try
set p to 1
tell application "Finder"
activate
set theExternalDisk to (my cccDisk)
set folderNames to name of (folders of (folder "Users" of theExternalDisk))
repeat with eachname in folderNames
if eachname is not in {"Guest", "Shared"} then
set theExternalUser to folder eachname of (folder "Users" of theExternalDisk)
exit repeat
end if
end repeat
set theMailStorage to every folder of folder "V4" of folder "Mail" of folder "Library" of theExternalUser
set repeatExit to true
repeat with eachCheckFolder in theMailStorage
set p to 2
set eachCycleFolder to (every folder of eachCheckFolder whose kind is "mail mailbox")
set p to 2.5
repeat with eachFolder in eachCycleFolder
set p to 3
if (name of eachFolder as text) starts with "Year " and name extension of eachFolder is "mbox" then
set p to 4
tell application "System Events" to display dialog (name of eachFolder) as text giving up after 2
set p to 5
set eachFolder to eachFolder as alias
set p to 6
my cleanUp(eachFolder)
end if
end repeat
end repeat
end tell
on error errmsg
tell application "System Events" to display dialog " First loop p = " & p & return & errmsg giving up after 20
end try
end tell
on error errmsg
tell application "System Events" to display dialog errmsg
end try
#
#
#
end nowCopyInformation
on cleanUp(box)
try
set keepbox to ""
set p to 1
tell application "Finder"
launch
set p to 2
set theCount to (count of (every folder of folder box whose kind is "mail mailbox"))
if theCount > 0 then
set p to 4
repeat with mbx in (get every folder of box whose kind is "mail mailbox")
set p to 5
my cleanUp(mbx as alias)
end repeat
else
set p to 6
tell application "Mail"
set p to 7
my importMail(box)
end tell
end if
end tell
on error errmsg number errnum
tell application "System Events" to display dialog "CleanUp " & errmsg & " number " & errnum & " p = " & p giving up after 20
end try
end cleanUp
on importMail(eachFolder)
tell application "Mail"
activate
try
say "importing"
import Mail mailbox at eachFolder
on error errmsg
tell application "System Events" to display dialog "Import " & errmsg giving up after 20
end try
end tell
end importMail