use*_*568 6 iphone xcode ios mfmailcomposeviewcontroller
我从这里找到了这个源代码并尝试使用它发送邮件.我成功获得了'MFMailComposeResultSent'消息,但未发送实际邮件.我不明白为什么不工作.另外,我附加了NSData中的图像,但它没有显示在mailcomposeview中.这段代码有什么问题?实际上,我只需要使用附件图像调用本机邮件应用程序,但我听说无法通过附件调用本机应用程序.请告诉我我的代码有什么问题.问题1:不从mailcomposeview发送邮件,问题2:不显示附加图像.最佳:运行附加图像的本机邮件应用程序.我很乐意等你的回答.谢谢.
-(void) sendMail
{
NSLog(@"Mail");
MFMailComposeViewController *mfMailView = [[MFMailComposeViewController alloc]init];
NSData *imgData = UIImagePNGRepresentation(imgPreview.image);
mfMailView.mailComposeDelegate = self;
[mfMailView addAttachmentData:imgData mimeType:@"image/png" fileName:@"Me.png"];
//also tried this
//[mfMailView addAttachmentData:imgData mimeType:@"image/png" fileName:@"Me"];
[mfMailView setSubject:@"TE~st"];
[mfMailView setMessageBody:@"Download Me~!" isHTML:YES];
[self presentModalViewController:mfMailView animated:YES];
}
-(void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
switch (result) {
case MFMailComposeResultCancelled:
NSLog(@"cancel?");
break;
case MFMailComposeResultSaved:
NSLog(@"saved?");
break;
case MFMailComposeResultSent:
NSLog(@"Sent succed");
[controller dismissModalViewControllerAnimated:YES];
break;
case MFMailComposeResultFailed:
NSLog(@"sent failue");
NSLog(@"%@",error);
break;
default:
break;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4273 次 |
| 最近记录: |