iOS学习笔记8-iOS 实现发送邮件和短信
来源:互联网 发布:windows caffe mnist 编辑:程序博客网 时间:2024/06/05 21:17
导入framework
导入MessageUI.framework
发送邮件
首先需要在.h文件中实现下面的操作:
- #import <MessageUI/MFMailComposeViewController.h>
- - (void)businessContactWithMail
- {
- Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
- if (mailClass != nil)
- {
- // We must always check whether the current device is configured for sending emails
- 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
- // Dismisses the email composition interface when users tap Cancel or Send.
- // Proceeds to update the message field with the result of the operation.
- - (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) {
- // Check whether the current device is configured for sending SMS messages
- 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学习笔记8-iOS 实现发送邮件和短信
- iOS 实现发送邮件和短信
- iOS 实现发送邮件和短信
- iOS 实现发送邮件和短信
- ios 发送邮件和短信
- iOS发送邮件和短信
- 小胖说事8------iOS 调用系统的短信和发送邮件功能,实现短信分享邮件分享
- iOS 发送短信 和 发送邮件方法
- iOS-调用系统的短信和发送邮件功能,实现短信分享邮件分享
- iOS-调用系统的短信和发送邮件功能,实现短信分享邮件分享
- iOS-调用系统的短信和发送邮件功能,实现短信分享邮件分享
- iOS-调用系统的短信和发送邮件功能,实现短信分享邮件分享
- iOS-调用系统的短信和发送邮件功能,实现短信分享邮件分享
- iOS-调用系统的短信和发送邮件功能,实现短信分享邮件分享
- iOS学习笔记28-系统服务(一)短信和邮件
- iOS学习笔记 系统服务(一)短信和邮件
- IOS 发送短信实现
- iOS 调用系统短信、邮件发送界面
- 南邮 OJ 1100 最长回文子串
- 触摸事件分发机制总结
- The hierarchy of the type MethodBeforeAdvice is inconsistent
- [网络流24题] 05 圆桌聚餐(最大流判满流)
- 【android自定义控件】android ListView添加侧滑删除
- iOS学习笔记8-iOS 实现发送邮件和短信
- Java中String、StringBuffer和StringBuilder详解
- php redis
- 橡皮擦(转)
- CentOS yum源默认安装路径
- LD_LIBRARY_PATH
- Android的ListView的每一个Item都有不同的布局
- 20150804-反射及注解
- 南邮 OJ 1101 Trees on the Level