0
A
回答
3
在您的视图控制器头。
然后:
-(void)showMailPanel {
MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init];
// only on iOS < 3
//if ([MFMailComposeViewController canSendMail] == NO)
// [self launchMailApp]; // you need to
mailComposeViewController.mailComposeDelegate = self;
[mailComposeViewController setToRecipients:[NSArray arrayWithObjects:@"email address1",@"email address 2",nil]];
[mailComposeViewController setSubject:@"your subject"];
[mailComposeViewController setMessageBody:@"your body" isHTML:YES];
mailComposeViewController.delegate = self;
[self.navigationController presentModalViewController:mailComposeViewController animated:YES];
[mailComposeViewController release];
}
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
// Notifies users about errors associated with the interface
switch (result)
{
case MFMailComposeResultCancelled:
NSLog(@"Result: canceled");
break;
case MFMailComposeResultSaved:
NSLog(@"Result: saved");
break;
case MFMailComposeResultSent:
NSLog(@"Result: sent");
break;
case MFMailComposeResultFailed:
NSLog(@"Result: failed");
break;
default:
NSLog(@"Result: not sent");
break;
}
[controller dismissModalViewControllerAnimated:YES];
}
-(void)launchMailApp {
{
NSString *recipients = @"dest_email";
NSString *email = [NSString stringWithFormat:@"%@%@", recipients, subject];
email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
}
2
都需要这样的东西:
//Import this in your .h file
#import <MessageUI/MessageUI.h>
...
MFMailComposeViewController *mailController = [[[MFMailComposeViewController alloc] init] autorelease];
mailController.mailComposeDelegate = self;
[mailController setSubject:[NSString stringWithFormat:@"Report a problem - #%@", yourUserID]];
[mailController setToRecipients:[NSArray arrayWithObject:@"[email protected]"]];
[self presentModalViewController:mailController animated:YES];
此外,父视图控制器(委托)需要符合MFMailComposeViewControllerDelegate协议:
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
//Extra implementation here...
[self dismissModalViewControllerAnimated:YES];
}
+0
这只用于发送静态邮件ID,但我需要动态发送。例如,应用程序运行时可以输入邮件标识主题和邮件内容,然后我想发送。 – Senthilkumar 2011-02-09 13:15:05
相关问题
- 1. 如何从iPhone应用程序发送邮件
- 2. 如何从iPhone应用程序发送邮件?
- 3. iPhone发送邮件应用程序
- 4. 从应用程序发送邮件
- 5. 从php应用程序发送邮件
- 6. 使用skpsmtpmessage问题从iphone应用程序发送邮件
- 7. IOS:发送邮件,而iPhone/iPad的邮件应用程序
- 8. 从我的iPhone发送电子邮件应用程序
- 9. Iphone从应用程序发送电子邮件
- 10. 从iPhone应用程序发送多部分电子邮件
- 11. 如何从Ruby程序发送邮件?
- 12. 如何从iphone应用程序发送邮件而不显示MFMailComposeViewController?
- 13. 如何从Windows Phone 8应用程序发送电子邮件?
- 14. 如何从我的Facebook应用程序发送电子邮件
- 15. 如何从Rails应用程序异步发送所有邮件
- 16. 如何从我的应用程序发送邮件
- 17. 如何从Java Web应用程序发送电子邮件
- 18. 如何通过Activesync从Android应用程序发送邮件?
- 19. 如何从我的C#应用程序发送电子邮件?
- 20. 如何从我的iOS应用程序发送邮件 - SWIFT
- 21. 如何从我的应用程序发送电子邮件?
- 22. 如何从应用程序发送电子邮件
- 23. 如何从Wicket应用程序发送电子邮件?
- 24. 我们如何从iPhone应用程序发送彩信附件?
- 25. 如何发送邮件到所需的用户从iphone应用
- 26. 用rails应用程序发送邮件
- 27. 用Android应用程序发送邮件
- 28. 从iPhone应用程序发送消息
- 29. MFMailComposeViewController从iPhone发送邮件
- 30. 发送电子邮件的iPhone应用程序
这只用于发送静态邮件ID,但我需要动态发送。例如,应用程序运行时可以输入邮件标识主题和邮件内容,然后我想发送。 – Senthilkumar 2011-02-09 13:14:23