我正在开发一个AppleScript-ObjC应用程序,它在Mail中生成一封电子邮件。我的UI有三个IBOutlet(两个文本字段和一个弹出菜单),用户可以在其中输入将填入电子邮件的文本。我可以将这些出口的值保存到变量中,但是当我尝试在 tell application“Mail”语句中使用这些变量时,我收到此错误:
AppleEvents:收到的mach msg不是预期的复杂类型 在getMemoryReference中。
这是打印在日志中的内容:
(
"<NSAppleEventDescriptor: 'ctxt'>",
": ",
"Status: MyProjectName, Part No.: 12345"
)
似乎ctxt(我认为是NSString)和AppleScript字符串之间存在差异,但我无法弄清楚如何转换为AppleScript字符串。如果你这样做,请告诉我。
以下是整个功能的代码:
-- IBOutlets
property theWindow : missing value
property statusMenu : missing value
property partNumberField : missing value
property projectNameField : missing value
on generateButtonClicked:sender
set projectName to projectNameField's stringValue() as text
set partNumber to partNumberField's stringValue() as text
set status to statusMenu's objectValueOfSelectedItem as text
set theSubject to (status & ": " & projectName & ", Part No.: " & partNumber) as string
log (class of theSubject) & ": " & theSubject
tell application "Mail"
try
set newMessage to make new outgoing message with properties {subject: theSubject, theContent: "", visible: true}
on error e
log e
end try
activate
end tell
end generateButtonClicked:
答案 0 :(得分:0)
set newMessage to make new outgoing message ¬
with properties {subject: theSubject, theContent: "", visible: true}
theContent
不是outgoing message
的属性。将其更改为content
。