Apple脚本错误609,电子邮件导出到Excel

时间:2017-11-10 08:17:28

标签: excel email applescript analytics

我有兴趣使用Excel对我的电子邮件进行一些基本的数据分析。在努力找到一种方法将我的收件箱/发件箱导出到Excel(.CSV)可读的任何内容后,我调整了一个Apple脚本,它突然在同一点崩溃(导出大约1300封电子邮件后)并返回错误消息

  

错误“邮件收到错误:连接无效。”编号-609

我的代码是:

tell application "Microsoft Excel"
    set LinkRemoval to make new workbook
    set theSheet to active sheet of LinkRemoval
    set value of range "D1" of theSheet to "Message"
    set value of range "C1" of theSheet to "Subject"
    set value of range "B1" of theSheet to "From"
    set value of range "A1" of theSheet to "Date"
end tell

with timeout of (30 * 60) seconds -- timeout set to 30 mins --
    tell application "Mail"
        set theRow to 2
        set theAccount to "Gmail"
        get account theAccount
        set theMessages to messages of mailbox "INBOX" of account "Gmail"
        -- target mailbox for extracting to excel--
        repeat with aMessage in theMessages
            my SetDate(date received of aMessage, theRow, theSheet)
            my SetFrom(sender of aMessage, theRow, theSheet)
            my SetSubject(subject of aMessage, theRow, theSheet)
            my SetMessage(content of aMessage, theRow, theSheet)
            set theRow to theRow + 1
        end repeat
    end tell

非常感谢任何建议!

0 个答案:

没有答案