在 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查看发送状态。
- ››iphone图片拉伸的几种方法
- ››iphone正则表达式的简单使用
- ››iPhone开发Unresolved Symbols CAKeyframeAnimati...
- ››IPhone开发-“此证书是由未知颁发机构签名”解决方...
- ››IPhone开发-整合私钥和证书,生成.p12文件
- ››iPhone应用开发-UIPickerView选取器详解
- ››iphone 获取屏幕的宽度和高度
- ››iPhone读取工程包中的二进制文件
- ››iPhone新手机 不挂YouTube APP
- ››iPhone 获取指定格式的时间和日期
- ››iPhone版PPS走进生活 观赏体验媲美PC版
- ››APP Loading页设计和App从当前页进入新页面交互
更多精彩
赞助商链接