J’utilise ce ScriptApple à copier coller dans l’éditeur de script mac : changer l’adresse ("@lenomdedomaine") sur laquelle effectuer l’extraction et le chemin
Seule limitation c’est nom de domaine, par nom de domaine !!
set outputList to {}
set phrase to « @lenomdedomaine.com » --changer lenomdedomaine
set saveFilePath to « /Users/votrenom/Desktop/tab-del file.txt » --changer votrenom
–drill down to message level and test for phrase
tell application « Mail »
set myAccounts to every account
repeat with thisAccount in myAccounts
tell thisAccount
set myMailboxes to every mailbox
repeat with thisMailbox in myMailboxes
tell thisMailbox
set myMesssages to every message
repeat with thisMessage in myMesssages
set messageDataList to {}
tell thisMessage
set senderAddress to extract address from sender
if senderAddress ends with phrase then
-- check sender
set end of outputList to (my tabFormatString(thisMessage))
else
set recipientAddresses to (recipients's address)
repeat with thisaddress in recipientAddresses
-- check each recipient
if thisaddress ends with phrase then
set end of outputList to (my tabFormatString(thisMessage))
exit repeat
end if
end repeat
end if
end tell
end repeat
end tell
end repeat
end tell
end repeat
end tell
set fp to open for access saveFilePath with write permission
write tid({input:outputList, delim:return}) to fp
close access fp
on tabFormatString(aMessage)
--build a tab delimited string from the relevant data
tell application "Mail"
tell aMessage
set messageFrom to sender
set messageToNameList to to recipients's name
set messageToAddressList to to recipients's address
set messageCCNameList to cc recipients's name
set messageCCAddressList to cc recipients's address
set messageBCCNameList to bcc recipients's name
set messageBCCAddressList to bcc recipients's address
set messageDate to (date received) as rich text
set messageSubject to subject
end tell
end tell
set txt to {messageFrom}
set end of txt to mungeParallelLists(messageToNameList, messageToAddressList)
set end of txt to mungeParallelLists(messageCCNameList, messageCCAddressList)
set end of txt to mungeParallelLists(messageBCCNameList, messageBCCAddressList)
set end of txt to messageDate
set end of txt to messageSubject
return tid({input:txt, delim:tab})
end tabFormatString
on mungeParallelLists(list1, list2)
-- utility to turn lists like {{name1, name2,…},{address1, address2, …}}
-- into "name1 <address1>, name2 <address2> ...
set tempList to {}
repeat with i from 1 to count of list1
set end of tempList to ((item i of list1 & " <" & item i of list2 & ">") as text)
end repeat
return tid({input:tempList, delim:", "})
end mungeParallelLists
on tid({input:input, delim:delim})
-- handler for text items
set {oldTID, my text item delimiters} to {my text item delimiters, delim}
if class of input is list then
set output to input as text
else
set output to text items of input
end if
set my text item delimiters to oldTID
return output
end tid