tell application "Mail"
set liste to every mailbox
repeat with i from 1 to count liste
try
item i of liste as rich text
on error errMsg
(*Il est impossible de rendre «class mbxp» "fournisseurs/Apple/iTunes Store" of application "Mail" en type text.*)
item 2 of my decoupe(errMsg, "» " & quote)
(*fournisseurs/Apple/iTunes Store” of application "Mail" en type text.*)
item 1 of my decoupe(result, quote & " of application")
(*fournisseurs/Apple/iTunes Store*)
set item i of liste to result
end try
end repeat
end tell
my recolle(liste, return)
my writeto((path to desktop as text) & "mailboxes.txt", result, text, false)
#=====
(*
*)
on writeto(targetFile, theData, dataType, apendData)
-- targetFile is the path to the file you want to write
-- theData is the data you want in the file.
-- dataType is the data type of theData and it can be text, list, record etc.
-- apendData is true to append theData to the end of the current contents of the file or false to overwrite it
try
set targetFile to targetFile as text
set openFile to open for access file targetFile with write permission
if not apendData then set eof of openFile to 0
write theData to openFile starting at eof as dataType
close access openFile
return true
on error
try
close access file targetFile
end try
return false
end try
end writeto
#=====
on decoupe(t, d)
local oTIDs, l
set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, d}
set l to text items of t
set AppleScript's text item delimiters to oTIDs
return l
end decoupe
#=====
on recolle(l, d)
local oTIDs, t
set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, d}
set t to "" & l
set AppleScript's text item delimiters to oTIDs
return t
end recolle
#=====