0

I am trying to create a plugin to OSX's Mail.app, a so called mailbundle that adds a custom mail header to the outgoing mail, like a "X-my-org-key: some_text"

I have managed to get it started and can "intercept" the send method but I am not sure if I add the header to the right type of instance since the actually sent mail lacks my header.

The code look like this:

#import "DocumentEditor.h"
#import "ComposeBackEnd.h"
#import "MCMutableMessageHeaders.h"
#import "MCOutgoingMessage.h"
#import "WFRSwizzler.h"
#import "DocumentEditor-WaitForReply.h"
@implementation DocumentEditor_WaitForReply
+ (void) load {
    [WFRSwizzler extendClass: @"DocumentEditor"
                   withClass: @"DocumentEditor_WaitForReply"];
}

- (void) WFR_send: (id) arg1 {
    NSLog(@"send Swizzled");
    ComposeBackEnd *backEnd = ((DocumentEditor *) self).backEnd;
    MCOutgoingMessage *message = [backEnd message];
    MCMutableMessageHeaders *headers = [message mutableHeaders];
    [headers setHeader:@"some_text" forKey:@"x-my-org-key"];
    [self WFR_send: arg1];
}

Any hints are welcome

StarsSky
  • 6,721
  • 6
  • 38
  • 63
Lucas
  • 31
  • 3
  • I’m curious what WFRSwizzler is doing to prevent the [self WFR_send:] call from looping forever? And is your “send Swizzled” log printing? – Wil Shipley Jan 28 '14 at 08:41
  • The WFRSwizzler basically looks like this: https://github.com/stl/MailBundle-Template/blob/master/Classes/Swizzler.m it checks the prefix of he method name. And yes the code get executed , I see the log and I could also debug it (I attach the debugger to the Mail.app process) – Lucas Jan 28 '14 at 13:19
  • This post explains Swizzler trick more: http://stackoverflow.com/questions/13294420/how-to-call-the-original-method-from-swizzled-one – Lucas Jan 28 '14 at 13:40

0 Answers0