开发者

How can I send attachments using iphone mail-core api?

I'm working on a proje开发者_如何学Goct in which I'm using the mail-core iphone api to send and retrieve mail. I have tried a lot of things, but have been unable to find any solution. I've tried searching but haven't found any solution. Could someone explain how to use the mail-core api to send attachments?. If anybody knows how to do that please let me know.


I haven't tested this but if you look at the header for CTCoreMessage, it does have a method addAttachment:. Argument for this is a CTCoreAttachment object.


Add this only and only after you setBody or setHTMLBody:

// Set Attachments
NSString *filePrefix = [[NSBundle mainBundle] bundlePath];
NSString *path = [NSString stringWithFormat:@"%@/%@",filePrefix,@"TestData/DSC_6201.jpg"];
NSLog(@"path:%@", path);

CTCoreAttachment *attach = [[CTCoreAttachment alloc] initWithContentsOfFile:path];
if ([attach data]==nil) {
    NSLog(@"Error: attachment data is nil");
}
[myMessage addAttachment:attach];

Here, you should add TestData folder with image to your project as a folder reference

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜