Email Apple脚本:更改符合条件的消息的标志

Email Apple脚本:更改符合条件的消息的标志,email,applescript,Email,Applescript,好的,我正在创建一个脚本,可以帮我阅读收到的邮件。 我坚持一件事: 如何更改符合我的条件的消息的标志,因为我正在检查循环中的未读消息,并且如果当前检查的消息匹配,则应将其标记。处理所选消息很容易,但如何在循环中标记消息 请看我的尝试: if (thisSubject contains projectName or thisSubject contains projectName1 or thisSubject contains projectName2 or thisSubject contai

好的,我正在创建一个脚本,可以帮我阅读收到的邮件。 我坚持一件事: 如何更改符合我的条件的消息的标志,因为我正在检查循环中的未读消息,并且如果当前检查的消息匹配,则应将其标记。处理所选消息很容易,但如何在循环中标记消息

请看我的尝试:

if (thisSubject contains projectName or thisSubject contains projectName1 or thisSubject contains projectName2 or thisSubject contains projectName3) then
        --mark required messages with red flag
        tell application "Mail"
            #set currentMail to thisMail
            set currentMail to selection
            repeat with s in currentMail
                set flag index of s to 1 as integer
            end repeat

        end tell
更新: 下面是一个循环,它应该用标记标记所有匹配的邮件

repeat with thisMail from 1 to count of theSubjects
set thisSubject to item thisMail of theSubjects
if (thisSubject contains searchWord or thisSubject contains searchWord2) then
    if (thisSubject contains projectName or thisSubject contains projectName1 or thisSubject contains projectName2 or thisSubject contains projectName3) then
        --mark required messages with flag  
        tell application "Mail"
            #   set allMessage to selection
            repeat with MyMessage in thisMail
                #   set read status of thisMail to true -- set read
                set flagged status of MyMessage to true -- display flag / false hide flag
                set flag index of MyMessage to 1 -- set first color for the flag (-1 remove the flag)
            end repeat
        end tell
    end if
end if  

结束重复

标志索引定义标志的颜色。要激活或不激活该标志,必须使用标记状态

下面是一个带有读取标志、打开/关闭标志和颜色标志的示例

set projectName1 to "test1"
set projectName2 to "test2"
set projectName3 to "test3"
set SearchWord1 to "Myword1"
set SearchWord2 to "Myword2"

tell application "Mail"
set allMessage to every message of inbox whose (subject contains projectName1) or (subject contains projectName2) or (subject contains projectName3) or (subject contains SearchWord1) or (subject contains SearchWord2)
repeat with MyMessage in allMessage
    set read status of MyMessage to true -- set read
    set flagged status of MyMessage to true -- display flag / false hide flag
    set flag index of MyMessage to 1 -- set first color for the flag (-1 remove the flag)
end repeat
end tell

是的,谢谢。但我的问题不在标志中,问题是我无法将此标志添加到邮件中,该邮件现在在循环中运行,并且符合某些条件。我收到了这个错误:
error”邮件收到了一个错误:无法将1转换为类型说明符。“number-1700从1转换为说明符”
删除“as integer”,然后您就有了与我相同的代码…这是有效的。是的,它有效,但在循环内它仅适用于当前选定的邮件,而不适用于符合条件的邮件。请参阅问题描述中的第二部分代码。我更改了第一个脚本,根据项目名称的3个可能值和搜索词的2个可能值包含您的筛选器。这样,标志被设置为仅匹配条件的消息。