0
votes

I'm working on an AppleScript-ObjC application that generates an email message in Mail. My UI has three IBOutlets (two text fields and a pop-up menu) where users can enter text that will be filled into the email. I can save the values from those outlets into variables, but when I try to use those variables inside my tell application "Mail" statement, I get this error:

AppleEvents: received mach msg which wasn't complex type as expected in getMemoryReference.

And here's what prints in the log:

(
    "<NSAppleEventDescriptor: 'ctxt'>",
    ": ",
    "Status: MyProjectName, Part No.: 12345"
)

It seems like there's a difference between ctxt (which I think is an NSString) and an AppleScript string, but I can't figure out how to convert to an AppleScript string. Please let me know how if you do.

Here's the code for the whole function:

-- 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:
1
Your Script is fine so far. the error is based on a bug in newest Xcodes(9.x). It's harmless and already known to Apple. The class is also fine as the values automatically get bridged to Apple events. Does the script do what you want? Then your finePat_Morita
My attempt to make a new message works when I hard-code strings in for subject, content, etc. But when I try to put in variables (theSubject, theContent), it doesn’t work and gives me the error I quoted above.rockitude

1 Answers

0
votes
set newMessage to make new outgoing message ¬
    with properties {subject: theSubject, theContent: "", visible: true}

theContent isn't a property of outgoing message. Change it to content.