首页 > 代码库 > ios发送邮件
ios发送邮件
ios发送邮件
by 伍雪颖
第一种:
NSString *myEmail = @"3423423423@qq.com"; NSString *toemail = @"asdfasdf@gmail.com"; NSString *emailDetail = [NSString stringWithFormat:@"mailto:%@?cc=%@&subject=Feedback!&body=Dear:",toemail,myEmail]; [[UIApplication sharedApplication] openURL: [NSURL URLWithString: emailDetail]];
第二种:
- (void)displayMailPicker { MFMailComposeViewController *mailPicker = [[MFMailComposeViewController alloc] init]; mailPicker.mailComposeDelegate = self; [mailPicker setSubject: @"Feedback!"]; NSArray *toRecipients = [NSArray arrayWithObject: @"3434234@qq.com"]; [mailPicker setToRecipients: toRecipients]; NSArray *ccRecipients = [NSArray arrayWithObjects:@"asdfa@gmail.com", nil]; [mailPicker setCcRecipients:ccRecipients]; // add a picture UIImage *addPic = [UIImage imageNamed: @"icon_logo@2x.png"]; NSData *imageData = UIImagePNGRepresentation(addPic); [mailPicker addAttachmentData: imageData mimeType: @"" fileName: @"Icon.png"]; NSString *emailBody = @"<font size='4'>Dear:</font>"; [mailPicker setMessageBody:emailBody isHTML:YES]; [self presentViewController:mailPicker animated:YES completion:nil]; } - (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error { [self dismissViewControllerAnimated:YES completion:nil]; }
一般用第二种
ios发送邮件
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。