• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Another 'Mail' hassle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Another 'Mail' hassle


  • Subject: Re: Another 'Mail' hassle
  • From: Yvan KOENIG <email@hidden>
  • Date: Fri, 28 Apr 2017 08:37:01 +0200


Le 28 avr. 2017 à 04:33, Brian Christmas <email@hidden> a écrit :

G’day All

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.

So, the code is now as below…

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.

on waitForMail()
tell application "Mail"
repeat while background activity count > 0
delay 1
end repeat
end tell
end waitForMail


Regards

Santa

<Screen Shot 2017-04-28 at 12.19.15 pm.png>

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


Hello Christopher


Annoying point : you use a test upon kind. Alas this property is localized so it failed. In french, "mail mailbox" is spelled : "Boîte aux lettres Mail"
Would be safer to test upon name extension which is not localized.
It's what I did to be able to test.
For the tests, the mailboxes were :
forum AppleScript FR
forum AppleScript shell
forum AppleScript US
Only the late two mailboxes (shell & US) were imported.
forum AppleScript FR was not.


Yvan KOENIG running Sierra 10.12.4 in French (VALLAURIS, France) vendredi 28 avril 2017 08:36:38




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Another 'Mail' hassle
      • From: Brian Christmas <email@hidden>
References: 
 >Re: Another 'Mail' hassle (From: Brian Christmas <email@hidden>)
 >Re: Another 'Mail' hassle (From: Brian Christmas <email@hidden>)
 >Re: Another 'Mail' hassle (From: Yvan KOENIG <email@hidden>)
 >Re: Another 'Mail' hassle (From: Brian Christmas <email@hidden>)

  • Prev by Date: Re: Another 'Mail' hassle
  • Next by Date: Re: Another 'Mail' hassle
  • Previous by thread: Re: Another 'Mail' hassle
  • Next by thread: Re: Another 'Mail' hassle
  • Index(es):
    • Date
    • Thread