我想要保存不同用户的电子邮件地址,我想点击电子邮件时打开mailBox的新邮件,就像iphone中的电话簿邮箱一样,
我该怎么做???
答案 0 :(得分:1)
在Mail中创建新邮件:
NSString *subject = @"The subject";
NSString *body = @"The message";
NSString *address = @"mail@address.com";
NSString *cc = @"mail@address.com";
NSString *path = [NSString stringWithFormat:@"mailto:%@?cc=%@&subject=%@&body=%@", address, cc, subject, body];
NSURL *url = [NSURL URLWithString:[path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:url];
答案 1 :(得分:1)
您应该使用MFMailComposeViewController
类和实现MFMailComposeViewControllerDelegate
协议
首先发送消息:
MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:@"My Subject"];
[controller setMessageBody:@"Hello there." isHTML:NO];
[self presentModalViewController:controller animated:YES];
[controller release];
一旦发送,您将在mailComposeController
中获得委托回调:
- (void)mailComposeController:(MFMailComposeViewController*)controller
didFinishWithResult:(MFMailComposeResult)result
error:(NSError*)error;
{
if (result == MFMailComposeResultSent) {
NSLog(@"It's gone!");
}
[self dismissModalViewControllerAnimated:YES];
}