【问题标题】:Process emails from mac using javascript (JXA) instead of applescript使用 javascript (JXA) 而不是 applescript 处理来自 mac 的电子邮件
【发布时间】:2018-08-11 19:12:38
【问题描述】:

我正在尝试在 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 中?

【问题讨论】:

    标签: macos applescript javascript-automation


    【解决方案1】:

    也许是这样的。希望这会有所帮助。

    (() => {
        '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()];
                ...
            }
    
        )
    })();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-01
      • 1970-01-01
      • 2018-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-09
      相关资源
      最近更新 更多