iOS 实现发送邮件和短信
来源:互联网 发布:java中文相似度匹配 编辑:程序博客网 时间:2024/06/01 07:22
导入framework
导入MessageUI.framework
发送邮件
首先需要在.h文件中实现下面的操作:
- #import <MessageUI/MFMailComposeViewController.h>
- - (void)businessContactWithMail
- {
- Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
- if (mailClass != nil)
- {
- // 我们必须经常检查是否当前的设备被配置为发送电子邮件
- if ([mailClass canSendMail])
- {
- MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
- picker.mailComposeDelegate = self;
- [picker setToRecipients:[NSArray arrayWithObject:@""]];
- [picker setSubject:[NSString stringWithFormat:@""]];
- UIDevice *device = [UIDevice currentDevice];
- NSString *content=[NSString stringWithFormat:@""];
- [picker setMessageBody:content isHTML:NO];
- [self presentViewController:picker animated:YES completion:^{
- }];
- }
- else
- {
- [NDUI showAlertWithInfo:@"您的设备尚未配置邮件账号" title:@"提示"];
- }
- } else {
- [NDUI showAlertWithInfo:@"您的设备不支持邮件功能" title:@"提示"];
- }
- }
- #pragma mark - Mail and SMS delegate
- // 解散撰写邮件界面当用户点击“取消”或发。
- // 进行操作的结果更新消息字段。
- - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
- {
- [self dismissViewControllerAnimated:YES completion:nil];
- }
短信发送
首先需要在.h文件中实现下面的操作:
- #import <MessageUI/MFMailComposeViewController.h>
- - (void)shareWithSMS
- {
- Class messageClass = (NSClassFromString(@"MFMessageComposeViewController"));
- BOOL smsEnabled=NO;
- if (messageClass != nil) {
- // 检查当前设备是否配置为发送短信
- if ([messageClass canSendText]) {
- MFMessageComposeViewController *smsClident = [[MFMessageComposeViewController alloc] init];
- smsClident.messageComposeDelegate = self;
- NSString *messageBody = [NSString stringWithFormat:@""];
- [smsClident setBody:messageBody];
- [self presentModalViewController:smsClident animated:YES];
- }
- else {
- [NDUI showAlertWithInfo:@"您的设备不支持此短信功能" title:@"提示"];
- }
- }
- else {
- [NDUI showAlertWithInfo:@"您的设备不支持短信功能" title:@"提示"];
- }
- if(!smsEnabled){
- return;
- }
- }
- - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
- {
- [self dismissModalViewControllerAnimated:YES];
- }
0 0
- iOS 实现发送邮件和短信
- iOS 实现发送邮件和短信
- iOS 实现发送邮件和短信
- ios 发送邮件和短信
- iOS发送邮件和短信
- iOS学习笔记8-iOS 实现发送邮件和短信
- iOS 发送短信 和 发送邮件方法
- iOS-调用系统的短信和发送邮件功能,实现短信分享邮件分享
- iOS-调用系统的短信和发送邮件功能,实现短信分享邮件分享
- iOS-调用系统的短信和发送邮件功能,实现短信分享邮件分享
- iOS-调用系统的短信和发送邮件功能,实现短信分享邮件分享
- iOS-调用系统的短信和发送邮件功能,实现短信分享邮件分享
- 小胖说事8------iOS 调用系统的短信和发送邮件功能,实现短信分享邮件分享
- iOS-调用系统的短信和发送邮件功能,实现短信分享邮件分享
- IOS 发送短信实现
- iOS中发送短信/发送邮件的实现 韩俊强的博客
- iOS 调用系统短信、邮件发送界面
- iOS开发-发送邮件及短信
- Remove Duplicates from Sorted List II--LeetCode
- 机器学习实战-k近邻算法
- Coderforces Round #296(DIV.2)
- 记忆化搜索 hdu 1331
- 自定义的选择工具不会自动绑定mapcontrol的selectionChange事件
- iOS 实现发送邮件和短信
- java中 equals 和 == 的区别
- 删除目录及目录下文件
- Android自定义组合控件的过程
- 网卡性能分析-Intel8257X芯片手册读后感
- 关于网站备案的44个问题
- 滤波算法总结
- Android自定义一个对话框
- Auto Layout用法剖析(1)