iOS调用系统发送短信和邮件分享

//发送邮件
-(void)sendMail:(NSString*)subject content:(NSString*)content{ MFMailComposeViewController*controller = [[[MFMailComposeViewControlleralloc]init]autorelease];
if([MFMailComposeViewControllercanSendMail])
{
[controllersetSubject:subject];
[controllersetMessageBody:contentisHTML:NO];
controller.mailComposeDelegate=self;
[selfpresentModalViewController:controlleranimated:YES];
}
} #pragma mark - MFMailComposeViewControllerDelegate
//邮件完成处理
-(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error{ [selfdismissModalViewControllerAnimated:YES]; if(result ==MessageComposeResultCancelled)
NSLog(@"Message cancelled");
elseif(result ==MessageComposeResultSent)
NSLog(@"Message sent");
else
NSLog(@"Message failed"); }
// 发送短信
- (void)sendSMS:(NSString*)bodyOfMessage recipientList:(NSArray*)recipients
{
MFMessageComposeViewController*controller = [[[MFMessageComposeViewControlleralloc]init]autorelease];
if([MFMessageComposeViewControllercanSendText])
{
controller.body= bodyOfMessage;
controller.recipients= recipients;
controller.messageComposeDelegate=self;
[selfpresentViewController:controlleranimated:YEScompletion:^{ }];
}
}
//处理发送完的响应结果
- (void)messageComposeViewController:(MFMessageComposeViewController*)controller didFinishWithResult:(MessageComposeResult)result
{
[selfdismissModalViewControllerAnimated:YES]; if(result ==MessageComposeResultCancelled)
NSLog(@"Message cancelled");
else if(result ==MessageComposeResultSent)
NSLog(@"Message sent");
else
NSLog(@"Message failed");
}
上一篇:curl 命令详解(转)


下一篇:SHDP--Working with HBase(三)之HBase+Phoenix实现分页