Question

Here's what I'm attempting to do: Let's assume that you are in mail and create a New blank mail message, then enter some data into it, such as body copy, etc. (in my case, the message was created through scripting bridge using the "Mail Contents of this Page" from safari... the main purpose of this process for my application.)

From my application, I want to select that message and assign it to:

MailOutgoingMessage *myMessage;

so that I can programmatically add recipients. I've tried several ways of doing this which seemed logical, but so far I haven't found the right combination, and the header file doesn't seem to be very clear to me (I'm new to scripting bridge.)

My initial thought was to try this:

mailMessage = [[mail outgoingMessages] lastObject];

Which should grab the last outgoing message created. It seems to work in that I am able to add recipients to mailMessage (though there have been a few times that I received unexpected results when multiple outgoing messages exist, such as adding the recipients to the wrong message) but attempting to log the subject line of the message:

NSLog(@"Subject = %@",[mailMessage subject]);

always returns NULL even though there is a subject clearly viewable in the subject field of the message. NULL is returned for any other parameter as well.

I'm gathering it must be a problem with my assignment to mailMessage above, because the only time I receive a NULL for message properties (or receive unexpected results) is if I try to point mailMessage to an existing outgoing message. If I create the mail message with scripting bridge, then I can retrieve all of the properties correctly.

Does anyone understand the hierarchy of the Mail scripting enough to tell me why I am getting NULLs for the parameters using the above assignment for mailMessage? What would the simplest way be go grab my message so that I can add recipients and later call the:

[myMessage send];

method? Any insight would be helpful. I've spent a week going through the mail.h header file and am quite literally at a loss as to what else to try at this point.

Was it helpful?

Solution

There's no way to (send, get or set the properties of the outgoing message) that the user or Safari has created.

It's a bug (it stopped working since Mac OS X 10.4), or some privacy/security considerations.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top