繁体   English   中英

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

[英]AppleScript to select the messages from Imap folder on Mail.app

我需要为 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".

任何帮助我指出正确的方向?

尝试这样的事情:

-- 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

最佳,SooTerKo / 汉堡

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM