我正在尝试在JXA中创建一个电子邮件解析器。我能够在applescript中做类似的事情:
tell application "Mail" to set theMessages to every message of mailbox "Inbox" of account "MyAcount" whose subject is equal to "Search Text"
repeat with aMessage in theMessages
tell application "Mail" to set {mContent, mDate} to {content, date received} of aMessage
......process each mail.....
end repeat
我如何在javascript中复制此内容?
答案 0 :(得分:0)
也许有这样的事情。希望这会有所帮助。
(() => {
'use strict';
const
appMail = Application('Mail'),
account = appMail.accounts.byName('MyAccount'),
inbox = account.mailboxes.byName('INBOX'),
listMessages = inbox.messages.whose({
subject: 'Search Text'
})();
return listMessages.map(x => {
const [mContent, mDateReceived] = [x.content(), x.dateReceived()];
...
}
)
})();