Debugging Mail extensions

I'm trying to rewrite an old AppleScript mail rule that I used extensively as a Mail extension using the MailKit framework and I've run into an issue.

Previously, when developing the script, it was possible to debug it by selecting the message I wanted it applied to and choosing the Mail.app menu item "Message/Apply Rules" This would re-execute my script and I could iterate over it as many times as I liked while developing.

I haven't found any great way of doing this for my extension with a MEMessageActionHandler. The closest I've found is to forward the message to myself and wait for it to come back in again over the internet, at which point the extension would get executed again. Needless to say, this makes debugging my MEMessageAction handler much slower.

I've tried a number of things in Mail.app to try and get it to re-execute my extension with a particular message without any luck. Does anyone know of a good process for debugging a MEMessageActionHandler that doesn't involve forwarding the message to myself over and over and waiting for it to come in each time?

Answered by DTS Engineer in 829796022

Have you considered logging output to a file or perhaps using OSLog?

Have you considered logging output to a file or perhaps using OSLog?

Well the problem isn't debugging things once it gets executed by Mail. The problem is getting Mail to execute my extension in the first place.

It does it after mail comes in, so I'm dependent on some incoming mail. This wasn't the case previously, since I could always select a message and hit the "Apply Rules" menu and force my code to get re-executed immediately.

Well, if your action is not being executed when you select the "Apply Rules" contextual menu command then that's probably worth a bug report.

Please file a bug report, include a sample script and some directions that can be used to reproduce the problem. And please post the FB number here. I'll check the status and provide an update (if there's anything to report) next time I do a sweep of forums posts where I've suggested bug reports.

Bug Reporting: How and Why? has tips on creating your bug report.

Debugging Mail extensions
 
 
Q