【问题标题】:AppleScript Error: Mail got an error: Unrecognized direct parameter type, please specify a string like "John Doe <jdoe@example.com>"AppleScript 错误:邮件出错:无法识别的直接参数类型,请指定一个字符串,如“John Doe <jdoe@example.com>”
【发布时间】:2021-10-03 00:11:01
【问题描述】:

我有一个脚本可以根据 to recipient 过滤电子邮件,但出现错误。

这是脚本:

tell application "Mail"
    set firstInboxMessage to the first message of mailbox "INBOX" of account "Account"
    set theEmail to extract address from to recipient of the firstInboxMessage
    set my text item delimiters to {"+", "@"}
    set mailboxName to text item 2 of theEmail
    set messageAccount to account of mailbox of the firstInboxMessage
    tell the messageAccount to if the name of its mailboxes does not contain ¬
        the mailboxName then make new mailbox at the end of its mailboxes ¬
        with properties {name:mailboxName}
    set newMailbox to the mailbox named mailboxName in the messageAccount
    set the mailbox of the firstInboxMessage to the newMailbox
end tell

这是错误:

Mail got an error: Unrecognized direct parameter type, please specify a string like "John Doe <jdoe@example.com>"

我认为这与 to recipient 在 AppleScript 中与 subjectsender 的分类方式不同这一事实有关,因为当我使用其中任何一个时,脚本运行良好。

任何帮助将不胜感激。

【问题讨论】:

    标签: macos email applescript


    【解决方案1】:

    两个问题:

    1. to recipient 是一个元素。可以有多个收件人。
    2. to recipient 的地址在address 属性中可用,extract address from 不需要。澄清一下:extract address from 应用于 John Doe &lt;jdoe@example.com&gt; 返回 jdoe@example.comto recipient 不包含这样的复合字符串。

    简单写

    set theEmail to address of to recipient 1 of the firstInboxMessage
    

    【讨论】:

      猜你喜欢
      • 2018-11-06
      • 1970-01-01
      • 2017-07-06
      • 1970-01-01
      • 2021-10-10
      • 2020-05-25
      • 2014-07-26
      • 2021-12-25
      • 1970-01-01
      相关资源
      最近更新 更多