0

I'm calling an AppleScript from inside my application. The relevant snippet of my code looks like so:

-(void)sendMail:(NSString*)addressStr
    {
    NSString *scriptString = <snip>
    @"end tell\n"   
    @"tell b to make new to recipient with properties {address:\"[email protected]\"}\n"
    @"send b\n"
    @"end tell\n";
    <snip>
}

The script with "hard-wired" email address runs perfectly, but I really want to use addresses out of our community database. I tried using a mutable string for the scriptString, then inserting the passed addressStr into it at an exact (known) index before passing scriptString to the AppleScript object. But if I remove (only) the address chars and try something like:

@"tell b to make new to recipient with properties {address:\"\"}\n"
<snip>
[scriptString insertString:addressStr atIndex:556];

...it either won't compile or gives an "Attempt to mutate immutable object (??) with insertString:atIndex:" error at runtime -- depending on what I try.

So either my syntax is wrong (P=0.95), or I'm trying to do the impossible with AppleScript. Can anyone help me out, please? Thanks a lot in advance :-)

1 Answer 1

2

You need to use [NSString stringWithFormat:@"... %@ ...", @"arg"].

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a million, Mike. It's working perfectly now! "Spasiba" :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.