Bonjour à tous,
j'utilise un petit script trouvé sur internet pour enregistrer mes mails au format .eml sur mon disque dur, il marche bien mais j'aimerais qu'il m'ajoute le nom de l'expéditeur (pas l'adresse complète, juste le nom) dans le nom du fichier mais je ne sais pas ce que je dois rajouter.
Voilà le script à l'heure actuelle :
Voilà, je vous remercie ^^
j'utilise un petit script trouvé sur internet pour enregistrer mes mails au format .eml sur mon disque dur, il marche bien mais j'aimerais qu'il m'ajoute le nom de l'expéditeur (pas l'adresse complète, juste le nom) dans le nom du fichier mais je ne sais pas ce que je dois rajouter.
Voilà le script à l'heure actuelle :
Bloc de code:
tell application "Mail"
set msgs to selection
if length of msgs is not 0 then
display dialog "Exporter le(s) mail(s) sélectionné(s)?"
if the button returned of the result is "OK" then
-- set up month parsing value for French Vanilla algorithm
set fixedDate to current date --or any other date
set month of fixedDate to January
-- set theFolder
set theFolder to choose folder with prompt "Enregistrer le(s) mail(s) exporté(s) vers..." without invisibles
repeat with msg in msgs
-- -- create new name prefix based on date
set msgDate to date received of msg
-- parse date
set theYear to year of msgDate
set theMonth to month of msgDate as integer
set theMonth to my addZero(theMonth as string)
set theDay to my addZero(day of msgDate as rich text)
set hrs to my addZero(hours of msgDate as rich text)
set mins to my addZero(minutes of msgDate as rich text)
set msgDate to "[" & theYear & "." & theMonth & "." & theDay & "] [" & hrs & "h" & mins & "]"
-- strip out funny characters that we don't want in a file name
set comparison_string to ":/[]"
set replacement_string to "->||"
set msgSubject to ""
repeat with c in (subject of msg as string)
set x to the offset of c in comparison_string
if x is not 0 then
set msgSubject to (msgSubject & character x of replacement_string) as string
else
set msgSubject to (msgSubject & c) as string
end if
end repeat
set msgSubject to my replaceText("Re- ", "", msgSubject)
set msgSubject to my replaceText("Re-", "", msgSubject)
set newFileName to (msgDate & " " & msgSubject & ".eml") as Unicode text
try
set fn to (theFolder as Unicode text) & newFileName
--set fn to "tmp:xxxxxxx.emlx"
--display dialog ("file name is: " & fn)
set fnid to open for access fn with write permission
write (get source of msg) to fnid
--save msg in fn -- as native format
close access fnid
on error errorMessage number errorNumber
display dialog errorMessage & " Error #" & errorNumber as rich text buttons {"Oops"}
end try
end repeat
-- ends processing of messages
display dialog "Export de " & length of msgs & " mail(s) réussi."
end if -- OK to export msgs
end if -- msgs > 0
end tell
on addZero(v)
if length of v < 2 then
return "0" & v
end if
return v
end addZero
on replaceText(find, replace, subject)
set prevTIDs to text item delimiters of AppleScript
set text item delimiters of AppleScript to find
set subject to text items of subject
set text item delimiters of AppleScript to replace
set subject to "" & subject
set text item delimiters of AppleScript to prevTIDs
return subject
end replaceText