• 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
Re1: Mail scripting : How to select… continuation...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re1: Mail scripting : How to select… continuation...


  • Subject: Re1: Mail scripting : How to select… continuation...
  • From: awaw <email@hidden>
  • Date: Tue, 13 May 2008 19:09:26 +0200

Below, my script.
I have higlighted the sequences for my question.
English comments in text clarify also the context.

Without the call subroutine this script give the waited result.

But I Think... that it's possible to be better!!!
I have tried to code a recursive subroutine.
But the test drive to error.

Then I saw that keyword of Mail application (container, mailboxes, …) was variables in the subroutine... Consequently…

If anyone has an idea

Gérard
---------------------------------

tell application "Mail"
activate
global Boites
set tempo to 1
set ListeCompte to {}
set NombreAccount to count of pop account
set indexCompte to 1
repeat NombreAccount times
set Compte to name of account indexCompte
set ListeCompte to ListeCompte & Compte
set indexCompte to indexCompte + 1
end repeat
set selected mailboxes of message viewers to {inbox}
delay tempo
set indexCompte to 1
set CompteParDefaut to item 1 of ListeCompte -- pour la fin.
repeat NombreAccount times
set Compte to item indexCompte of ListeCompte
set selected mailboxes of first message viewer to {mailbox "INBOX" of account Compte}
delay tempo
set indexCompte to indexCompte + 1
end repeat
set selected mailboxes of message viewers to {outbox}
delay tempo
set selected mailboxes of message viewers to {sent mailbox}
delay tempo
set indexCompte to 1
repeat NombreAccount times
set Compte to item indexCompte of ListeCompte
set selected mailboxes of first message viewer to {mailbox "Sent" of account Compte}
delay tempo
set indexCompte to indexCompte + 1
end repeat
set selected mailboxes of message viewers to {trash mailbox}
delay tempo
set selected mailboxes of message viewers to {mailbox "Deleted Messages"}
delay tempo
set indexCompte to 1
repeat NombreAccount times
set Compte to item indexCompte of ListeCompte
set selected mailboxes of first message viewer to {mailbox "Trash" of account Compte}
delay tempo
set indexCompte to indexCompte + 1
end repeat
set selected mailboxes of message viewers to {junk mailbox}
delay tempo
--set selected mailboxes of message viewers to {mailbox "Deleted Messages"}
--delay tempo
set indexCompte to 1
repeat NombreAccount times
set Compte to item indexCompte of ListeCompte
set selected mailboxes of first message viewer to {mailbox "Junk" of account Compte}
delay tempo
set indexCompte to indexCompte + 1
end repeat
-- 
set B1 to mailboxes whose its name of container is missing value
set B2 to mailboxes whose its name of container is not missing value
set Boites to B1 & B2
-- Il faudrait trier (ordonner) les boites…
set NbreBoites to count of Boites
set liste to {} -- Création ch  vide
set flag to false
set indexListeBoites to 1
set a to name of item indexListeBoites of Boites as text
--display alert a
repeat NbreBoites times
(* Call subroutine 
  It's an example... and he doesn't run...
       *)
set ch to my QuelContainer(a, indexListeBoites, liste) -- Attempt to use a RECURSIVE SubRoutine
-------------------------------------------------------------------------------==================================
display alert ch
(* The code below is to make up for the upper call subroutine 
It's OK. Of course without the upper call subroutine.
*)
set flag to false
set a to name of item indexListeBoites of Boites as text
set ch to a
try
set a2 to name of container of item indexListeBoites of Boites as text
set ch to a2 & "/" & ch
on error
set ch to text 2 thru -1 of ch
set liste to liste & ch
set flag to true
end try
if flag is false then
try
set a3 to name of container of container of item indexListeBoites of Boites as text
set ch to a3 & "/" & ch
on error
set ch to text 2 thru -1 of ch
set liste to liste & ch
set flag to true
end try
end if
if flag is false then
try
set a4 to name of container of container of container of item indexListeBoites of Boites as text
set ch to a4 & "/" & ch
on error
set ch to text 2 thru -1 of ch
set liste to liste & ch
set flag to true
end try
end if
if flag is false then
try
set a5 to name of container of container of container of container of item indexListeBoites of Boites as text
set ch to a5 & "/" & ch
on error
set ch to text 2 thru -1 of ch
set liste to liste & ch
set flag to true
end try
end if
if flag is false then
try
set a6 to name of container of container of container of container of container of item indexListeBoites of Boites as text
set ch to a6 & "/" & ch
on error
set ch to text 2 thru -1 of ch
set liste to liste & ch
set flag to true
end try
end if
if flag is false then
try
set a7 to name of container of container of container of container of container of container of item indexListeBoites of Boites as text
set ch to a7 & "/" & ch
on error
set ch to text 2 thru -1 of ch
set liste to liste & ch
set flag to true
end try
end if
if flag is false then
try
set a8 to name of container of container of container of container of container of container of container of item indexListeBoites of Boites as text
set ch to a8 & "/" & ch
on error
set ch to text 2 thru -1 of ch
set liste to liste & ch
set flag to true
end try
end if
if flag is false then
try
set a9 to name of container of container of container of container of container of container of container of container of item indexListeBoites of Boites as text
set ch to a9 & "/" & ch
on error
set ch to text 2 thru -1 of ch
set liste to liste & ch
set flag to true
end try
end if
if flag is false then
try
set a10 to name of container of container of container of container of container of container of container of container of container of item indexListeBoites of Boites as text
set ch to a10 & "/" & ch
on error
set ch to text 2 thru -1 of ch
set liste to liste & ch
set flag to true
end try
end if
if flag is false then
try
set a11 to name of container of container of container of container of container of container of container of container of container of container of item indexListeBoites of Boites as text
set ch to a11 & "/" & ch
on error
set ch to text 2 thru -1 of ch
set liste to liste & ch
set flag to true
end try
end if
if flag is false then
try
set a12 to name of container of container of container of container of container of container of container of container of container of container of container of item indexListeBoites of Boites as text
set ch to a12 & "/" & ch
on error
set ch to text 2 thru -1 of ch
set liste to liste & ch
set flag to true
end try
end if
set indexListeBoites to indexListeBoites + 1
end repeat
set indexListe to 1
--set x to choose from list liste -- pour voir la ch  avant la boucle.
repeat count of liste times
set La_Boite to item indexListe of liste
set La_Boite to La_Boite as text
set selected mailboxes of message viewers to {mailbox La_Boite}
set indexListe to indexListe + 1
delay tempo
end repeat
-- +++++++++++++++++++
(*
Ici ça coince... "sur mon Mac" n'est pas une vraie boîte.
set selected mailboxes of message viewers to {mailbox "Sent" of account "sur mon Mac"}
Mais…
On peut l'avoir par :
set selected mailboxes of message viewers to {mailbox "Deleted Messages"}
*)
--set NbreDeleted to count of messages of mailbox "Deleted Messages" of trash mailbox of application "Mail"
--display alert "Il y a " & NbreDeleted & " messages dans \"sur mon Mac\"."
-- Il reste le cas "sur mon Mac" chez les junkies…
-- set NbreDeleted to count of messages of mailbox "Junked Messages" of junk mailbox of application "Mail"
-- display alert "Il y a " & NbreDeleted & " messages dans \"sur mon Mac\"."
set selected mailboxes of first message viewer to {mailbox "INBOX" of account CompteParDefaut}
-- On se positionne sur le premier compte.
end tell

on QuelContainer(boite, indexB, LaListe)
(*
The code is surely bad but IT'S NOT THE MATTER!...
The matter is "container" which is a VARIABLE here! 
Why?
*)
global Boites
set ch to boite
try
set a2 to name of container of item indexB of Boites as text
-------------------------!!!!!!!!!!!!! ---------------------------------------------------> container is a variable.
-- Probably because, here, the context application "Mail" is lost.
-- But where is the way out?
set ch to QuelContainer(a2, indexB, LaListe) & "/" & ch
on error
set ch to text 1 thru -1 of ch
set LaListe to LaListe & ch
return LaListe
end try
end QuelContainer


 _______________________________________________
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: Re1: Mail scripting : How to select… continuation...
      • From: Philip Aker <email@hidden>
References: 
 >Mail scripting : How to select… (From: awaw <email@hidden>)
 >Re: Mail scripting : How to select… (From: Luther Fuller <email@hidden>)
 >Re: Mail scripting : How to select… (From: awaw <email@hidden>)
 >Re: Mail scripting : How to select… (From: Axel Luttgens <email@hidden>)
 >Re1: Mail scripting : How to select… (From: awaw <email@hidden>)
 >Re: Re1: Mail scripting : How to select… (From: Axel Luttgens <email@hidden>)
 >Re: Re1: Mail scripting : How to select… (From: awaw <email@hidden>)
 >Re: Re1: Mail scripting : How to select… (From: Axel Luttgens <email@hidden>)

  • Prev by Date: Re: Circle-Slash
  • Next by Date: Re: Re1: Mail scripting : How to select… continuation...
  • Previous by thread: Re: Re1: Mail scripting : How to select…
  • Next by thread: Re: Re1: Mail scripting : How to select… continuation...
  • Index(es):
    • Date
    • Thread