1 (editado por botanist 26.06.2024 19:50:27)

Tema: Apple script para exportar datos de emails en Apple Mail a csv

Hola a todos

estoy intentando exportar la info de un conjunto de mails a un archivo csv.

En teoría el script permite seleccionar un número n de mensajes y luego al hacer correr el script, se debería generar un documento de numbers con la info de los mensajes.  AL compilarlo Apple Script no indica error de sintaxis, pero al correrlo  me da un error.
les copio el script y les copio el error, será que alguien se le ocurre lo que pueda estar mal?

gracias!

Botanist

SCRIPT
set dataLst to {{"SenderAddress", "SenderName", "Date", "Time", "Content"}}

tell application "Mail"
    repeat with aMsg in items of (get selection)
        tell aMsg
            set senderNameAddr to my splitEmail(sender)
            set senderAddr to item 2 of senderNameAddr
            set senderName to item 1 of senderNameAddr
            set msgSubj to subject
            set msgDate to date received
            set msgTime to time string of msgDate
            set msgDate to my dateFormat(date string of msgDate)
            set msgContent to content
            set msgLst to {senderAddr, senderName, msgDate, msgTime, msgContent}
            copy msgLst to dataLst's end
        end tell
    end repeat
end tell

tell application "Numbers"
    set newDoc to make new document
    tell table 1 of active sheet of newDoc
        delete column "A" -- remove default Header Column
        set column count to length of item 1 of dataLst
        set row count to (length of dataLst)
        repeat with i from 1 to length of dataLst
            repeat with j from 1 to length of item 1 of dataLst
                set value of cell j of row i to item j of item i of dataLst
            end repeat
        end repeat
    end tell
end tell

to dateFormat(aDateString) --> yyyy-mm-dd
    set {year:y, month:m, day:d} to date aDateString
    tell (y * 10000 + m * 100 + d) as string to text 1 thru 4 & "-" & text 5 thru 6 & "-" & text 7 thru 8
end dateFormat

to splitEmail(nameAddress)
    set text item delimiters to "<"
    tell nameAddress
        set theName to text item 1
        set theAddress to text 1 thru -2 of text item 2
    end tell
    return {theName, theAddress}
end splitEmail

ERROR
error "Numbers got an error: Can’t make class document." number -2710 from document to class

MBP 15 retina
Magno amore in familiam synantherarum captus.... (Lessing 1829)
http://www.flickr.com/photos/15922298@N02/