在 iPhone App 里发送带附件 Email 的实现代码
2010-05-29 05:40:00 来源:WEB开发网想在iPhone App里添加能发送附件的Email功能。可以加入messageUI.framework
添加附件代码
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString *pathHome = [path objectAtIndex:0];
NSString *filePath = [pathHome stringByAppendingPathComponent:@"info.txt"];
if( [MFMailComposeViewController canSendMail] )
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@" "];
NSLog(@"filePath = %@",filePath);
NSData* data = [NSData dataWithContentsOfFile:filePath];
[picker addAttachmentData:data mimeType:@"txt" fileName:@"info.txt"];
NSString *emailBody = @" ";
[picker setMessageBody:emailBody isHTML:YES];
[self presentModalViewController:picker animated:YES];
[picker release];
}
用回调函数mailComposeController查看发送状态。
- ››Applying Styles and Themes - 应用Style和Theme ...
- ››iPhone应用帮助残障儿童看图说话
- ››iPhone实用工具AppBox Pro使用教程大揭秘
- ››iphone4省电方法
- ››iphone 获取地址的详细信息
- ››iPhone 库的基本内存管理策略
- ››iPhone加密文字亲手做 私密信息有保障
- ››iphone 根据经纬度坐标取详细地址(包括国,省,市...
- ››iphone/ipad ios cocoa object-c 近期苹果UI部分小...
- ››iphone中如何进行多线程编程
- ››iPhone OS SDK的这些事[安装、下载、版本、实例、...
- ››iPhone ObjectC的NSAutoreleasePool
更多精彩
赞助商链接