我正在尝试运行通过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
关于我做错的任何想法?谢谢!
答案 0 :(得分: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}
请注意,在上面的示例中,更简单的l
形式也有效:
make new to recipient at end of to recipients with properties {address:l}
但我假设这是一个简化的示例,您的真实用例涉及从CSV文件中提取文本。