Applescript gefunden! Brauch aber Hilfe bei Unicode...
Hallo habe ein passendes Script hier gefunden:
http://www.mactechnews.de/forum/discussion/Freche-Frage-AppleScript-das-alle-ausgewaehlten-Mails-einzeln-als-reine-Datei-in-einen-Ordner-speichert-313262.html
Enthält eine Mail nun Umlaute, werden diese leider in der Zeile:
set theText to source of theMessage
als MacRoman eingelesen. Ich schaffe es leider nicht den kompletten Inhalt gleich als UTF8 einzulesen.
Weiß jemand von euch wie man das hinbekommt?
http://www.mactechnews.de/forum/discussion/Freche-Frage-AppleScript-das-alle-ausgewaehlten-Mails-einzeln-als-reine-Datei-in-einen-Ordner-speichert-313262.html
Show Plain Text
- global theFile
- set ptd to choose folder
- tell application "Mail"
- set theMessages to selection
- repeat with theMessage in theMessages
- set theText to source of theMessage
- -- set theText to content of theMessage -- (Inhalt der E-Mail)
- -- set theText to source of theMessage as «class utf8»
- -- set theText to paragraphs of (theMessage as «class utf8»)
- set theSubject to (subject of theMessage)
- if theSubject is "" then set theSubject to ":kein:betreff:"
- if theSubject contains ":" then ¬
- set theSubject to my snr(theSubject, ":", "_")
- if theSubject contains "/" then ¬
- set theSubject to my snr(theSubject, "/", "_")
- set msgDate to date received of theMessage
- set {year:y, month:m, day:d, hours:h, minutes:min} to (msgDate)
- set y to characters 3 through 4 of (y as string)
- set msgDate to (y & my pad2(m as integer) & my pad2(d))
- set theFile to ((ptd & msgDate & space & theSubject) & ".eml") as string
- my resolveConflict(ptd, msgDate, theSubject)
- set theFileID to open for access file theFile with write permission
- write theText to theFileID as «class utf8»
- close access theFileID
- end repeat
- end tell
- on pad2(n)
- return text -2 thru -1 of ("00" & n)
- end pad2
- on resolveConflict(ptd, msgDate, theSubject)
- tell application "Finder"
- set theCounter to 1
- set noConflict to false
- repeat until noConflict
- if exists file (theFile) then
- set theFile to ((ptd & msgDate & space & theSubject & " -" & theCounter as string) & ".eml")
- set theCounter to theCounter + 1
- else
- set noConflict to true
- end if
- end repeat
- end tell
- end resolveConflict
- on snr(theString, searchString, replaceString)
- tell (a reference to my text item delimiters)
- set {oldTID, contents} to {contents, searchString}
- set {theString, contents} to {theString's text items, replaceString}
- set {theString, contents} to {theString as Unicode text, oldTID}
- end tell
- return theString
- end snr
Enthält eine Mail nun Umlaute, werden diese leider in der Zeile:
set theText to source of theMessage
als MacRoman eingelesen. Ich schaffe es leider nicht den kompletten Inhalt gleich als UTF8 einzulesen.
Weiß jemand von euch wie man das hinbekommt?