想要从mailbundle(Mail.app插件)添加自定义邮件头

时间:2014-01-27 20:06:12

标签: objective-c macos cocoa email

我正在尝试为OSX的Mail.app创建一个插件,这是一个所谓的mailbundle,它为外发邮件添加了一个自定义邮件头,比如“X-my-org-key:some_text”

我已经设法启动并可以“拦截”发送方法,但我不确定是否将标头添加到正确类型的实例,因为实际发送的邮件缺少我的标题。

代码如下所示:

#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];
}

欢迎任何提示

0 个答案:

没有答案