在 App 里发送带附件 Email 的实现代码
来源:互联网 发布:cf辅助官网源码 编辑:程序博客网 时间:2024/06/11 04:14
源自:http://www.cocoachina.com/iphonedev/sdk/2010/0528/1572.html
在 App 里发送带附件 Email 的实现代码
想在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查看发送状 态。
添加附件代码
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查看发送状 态。
- 在 App 里发送带附件 Email 的实现代码
- iPhone App里添加能发送附件的Email功能
- 【java】实现发送带附件email
- 用JavaMail发送带附件的Email
- 使用PowerShell发送带附件的Email
- java发送Email,带附件
- 发送email(带附件)
- Java发送email 带附件
- python发送Email 带附件
- PHP发送带附件邮件的实现代码
- 【原创】用php发送带附件的email
- python 使用smtplib发送带附件的email
- Android 调用系统Email发送带多附件的邮件
- java发送email带附件完整的web工程
- 发送email(不带附件)
- ubuntu命令行直接发送email,带附件
- VB2013 发送邮件(Email)并带附件
- unity3d实现发送带附件的邮件
- c语言求助
- VC:进程间通信
- OOA&D实践之路——真实案例解析OO理论与实践(二)
- hdu--2503--分数求和
- ATL与MFC消息分发机制的对比
- 在 App 里发送带附件 Email 的实现代码
- axis
- IT人员及程序员怎样学好英语(关于如何利用极其有限的时间和条件学好英文)
- 说话
- apache 日志文件 处理方法
- 企业上完ERP之后干什么?
- RedHat实现多网卡绑定
- 【设计模式】交互图
- linux内核设计与实现摘录