AppleScript 错误:邮件出现错误:无法识别的直接参数类型,请指定类似“John Doe <jdoe@example.com>"的字符串 [英] AppleScript Error: Mail got an error: Unrecognized direct parameter type, please specify a string like &quot;John Doe &lt;jdoe@example.com&gt;&quot;

查看:14
本文介绍了AppleScript 错误:邮件出现错误:无法识别的直接参数类型,请指定类似“John Doe <jdoe@example.com>"的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本可以根据 收件人 过滤电子邮件,但是我收到了一个错误.

I have a script that filters emails based on the to recipient but I'm getting an error.

这是脚本:

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>"

我认为这与以下事实有关当我使用其中任何一个时,脚本运行良好.

I think it has to do with the fact that to recipient is classified differently somehow in AppleScript compared to for example subject or sender because when I use either of those the script runs fine.

任何帮助将不胜感激.

推荐答案

两个问题:

  1. to receiver 是一个元素.可以有多个收件人.
  2. 收件人的地址在address属性中可用,不需要extract address from.澄清一下:extract address from 应用到 John Doe <jdoe@example.com> 返回 jdoe@example.com 但一个 to 收件人 不包含这样的复合字符串.
  1. to recipient is an element. There can be more than one recipient.
  2. The address of to recipient is available in the address property, extract address from is not needed. To clarify it: extract address from applied to John Doe <jdoe@example.com> returns jdoe@example.com but a to recipient doesn't contain such a compounded string.

简单写

set theEmail to address of to recipient 1 of the firstInboxMessage

这篇关于AppleScript 错误:邮件出现错误:无法识别的直接参数类型,请指定类似“John Doe <jdoe@example.com>"的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆