【发布时间】:2018-04-29 15:14:50
【问题描述】:
我需要为 Mail.app 编写一个 Applescript,它将邮件的主题导出到 Excel 工作表中。
我在网上找到的可以做到这一点的衣柜代码如下:
tell application "Microsoft Excel"
set theSpamFile to make new workbook
set theSheet to active sheet of theSpamFile
set formula of range "B1" of theSheet to "Subject"
set formula of range "A1" of theSheet to "From"
end tell
tell application "Mail"
set theRow to 2
get mailboxes
set theMessages to messages of junk mailbox
repeat with aMessage in theMessages
my SetFrom(sender of aMessage, theRow, theSheet)
my SetSubject(subject of aMessage, theRow, theSheet)
set theRow to theRow + 1
end repeat
end tell
on SetFrom(theSender, theRow, theSheet)
tell application "Microsoft Excel"
set theRange to "A" & theRow
set formula of (range theRange) of theSheet to theSender
end tell
end SetFrom
on SetSubject(theSubject, theRow, theSheet)
tell application "Microsoft Excel"
set theRange to "B" & theRow
set formula of range theRange of theSheet to theSubject
end tell
end SetSubject
这些代码适用于邮箱垃圾。
但我不知道如何操作代码来选择 Mail.app 中 Imap 帐户子文件夹中的邮件。
我在 Mail.app 中有几个 Imap 帐户。两个gmail账号,一个iCloud账号等等。我还在每个Imap账号下创建了折叠和子文件夹。
我想从子文件夹中导出未读邮件:它位于“Google/Supplier/SupplierUpdate”
我试图从
更改选择行set theMessages to messages of junk mailbox
到
set theMessages to messages of mailbox"[Google]/DobaSupplierUpdate/DobaCancellation"
但脚本编辑器一直显示以下消息:
Mail got an error: Can’t get mailbox "[Google]/DobaSupplierUpdate/DobaCancellation".
有什么帮助可以指引我正确的方向吗?
【问题讨论】:
标签: excel email applescript directory imap