Question

When using the Scripting Bridge to access the Mail app one can easily retrieve an email of type MailMessage.

Accessing the contents of the mail however is another story. The body is stored in a content property of type MailRichText and I have no idea whatsoever as to how to recover the entire text in an NSString or NSAttributedString or other. It also seems there aren't any docs about this (or I missed them).

So can anyone help me? It seems the content is split up in paragraphs and words etc etc but I don't see how to even get one word of the mail out of all this?

There seems to be no end once you start digging in that class

Example:

MailRichText * content = message.content;

[[[[[[[[content words] lastObject] characters] lastObject] attributeRuns] lastObject] words] lastObject]  etc.. etc.. etc..

And nowhere there is even 1 character! Thanks!

Was it helpful?

Solution

Well, it seems i've found it after all:

MailRichText * content = message.content;
id result = [content get];
NSLog(@"%@",result);

Prints the text body of the mail.

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