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

我有兴趣使用Excel对我的电子邮件做一些基本的数据分析。 在努力find一种方法将我的收件箱/发件箱导出为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 

非常感谢您的任何build议!