我在应用程序的documents目录中存储了一个VideoClip.mp4。我可以使用SKPSMTPMessage成功发送电子邮件,(电子邮件、主题、正文等)但我在附加视频时遇到了问题。我已经找了很多,但我会继续找的。如果有人能帮助我,我将不胜感激。谢谢!
这段代码(显然)附加了一张图片,但我还不知道如何操作它来附加视频:
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];发布于 2012-12-10 22:06:33
这是一个迟来的答案,但希望它能帮助一些人。
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];https://stackoverflow.com/questions/11642087
复制相似问题