AppleScript从Mail.app上的Imap文件夹中选择消息

春衣少年当酒歌,起舞四顾以笑和。这篇文章主要讲述AppleScript从Mail.app上的Imap文件夹中选择消息相关的知识,希望能为你提供帮助。
我需要为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 tellon 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 SetFromon 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".

有什么帮助指出我正确的方向?
答案【AppleScript从Mail.app上的Imap文件夹中选择消息】尝试这样的事情:
-- set your email address here to find your account set targetAccount to first item of (every account whose user name is "xxx@googlemail.com") -- define the wanted subfolders here starting with deepest level set theMessages to every message of mailbox "SupplierUpdate" of mailbox "Supplier" of targetAccount whose read status is false

最好的,ShooTerKo /汉堡

    推荐阅读