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

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

我有一个根据 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 不同这一事实有关,因为当我使用其中任何一个脚本时运行良好。

如有任何帮助,我们将不胜感激。

两期:

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

随便写

set theEmail to address of to recipient 1 of the firstInboxMessage