1

我正在尝试运行通过 Apple Mail 发送电子邮件的 AppleScript。它似乎工作正常,但是当我运行脚本时出现错误。

这是我看到的错误:

error "Can’t get text item 1 of \"\"." number -1728 from text item 1 of ""

这是我的脚本:

set csv to read "/Users/Username/Documents/file.csv" as «class utf8»
set text item delimiters to ","
repeat with l in paragraphs of csv
    tell application "Mail"
        tell (make new outgoing message)
            set subject to "subject"
            set content to "content"
            make new to recipient at end of to recipients with properties {address:text 
            item 1 of l}
            send
        end tell
    end tell
end repeat

这是我的 CSV:

email1@gmail.com
email2@gmail.com

关于我做错了什么的任何想法?谢谢!

4

1 回答 1

1

的内容text item 1 of l是字面上text item 1 of的,然后是任何文本——也就是说,它没有被取消引用到一个简单的字符串。大多数时候这很好,但某些操作不会接受文本,除非它被取消引用。在这种情况下,您可以使用text item 1 of l as string,即:

make new to recipient at end of to recipients with properties {address:text item 1 of l as string}

请注意,在上面的示例中,更简单的 just 形式l也可以:

make new to recipient at end of to recipients with properties {address:l}

但我假设这是一个简化的示例,您的实际用例涉及从 CSV 文件中提取文本。

于 2014-10-26T03:47:41.750 回答