在SKPSMTPMessage中附加一个video
我有我的应用程序中存储在我的文档目录中的VideoClip.mp4。 我可以用SKPSMTPMessage(电子邮件,主题,正文等)成功发送电子邮件,但是我无法连接video。 我已经搜查了很多,但我会继续寻找。 如果有人能帮助我,那将非常感激。 谢谢!
这个代码(显然)附加了一个图像,但我一直无法弄清楚如何操作它来附加video:
NSString *image_path = [[NSBundle mainBundle] pathForResource:@\"Success\" ofType:@\"png\"]; NSData *image_data = [NSData dataWithContentsOfFile:image_path]; NSDictionary *image_part = [NSDictionary dictionaryWithObjectsAndKeys: @\"inline;\r\n\tfilename=\\"Success.png\\"\",kSKPSMTPPartContentDispositionKey, @\"base64\",kSKPSMTPPartContentTransferEncodingKey, @\"image/png;\r\n\tname=Success.png;\r\n\tx-unix-mode=0666\",kSKPSMTPPartContentTypeKey, [image_data encodeWrappedBase64ForData],kSKPSMTPPartMessageKey, nil];
这是一个迟到的答案,但希望它可以帮助别人。 假设你从文档目录( videoPath
)知道你的video文件的path,这里是代码:
NSData *videoData = [NSData dataWithContentsOfFile: videoPath]; NSDictionary *videoPart = [NSDictionary dictionaryWithObjectsAndKeys:@"video/quicktime;\r\n\tx-unix-mode=0644;\r\n\tname=\"video.mov\"",kSKPSMTPPartContentTypeKey, @"attachment;\r\n\tfilename=\"video.mov\"",kSKPSMTPPartContentDispositionKey,[videoData encodeBase64ForData],kSKPSMTPPartMessageKey,@"base64",kSKPSMTPPartContentTransferEncodingKey,nil];
然后你可以像这样将它附加到SKPSMTPMessage *testMsg
对象(假设你有剩下的testMsg
所需的属性集,像凭证等):
testMsg.parts = [NSArray arrayWithObjects: videoPart,nil];