AppleScript从Mail.app上的Imap文件夹中选择消息
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 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
最好的,ShooTerKo /汉堡
以上是关于AppleScript从Mail.app上的Imap文件夹中选择消息的主要内容,如果未能解决你的问题,请参考以下文章
如何在Mail.app中运行的applescript中使用钥匙串中的密码?
用Ruby和rb-appscript代替Applescript发送苹果邮件
从我在 iOS 上的应用程序通过 mail.app 发送电子邮件