-1
我正在发送邮件从iphone应用 我希望,而不是这个静态接待用户应该输入到邮件领域和邮件应发送给他们。如何发送邮件到所需的用户从iphone应用
- (void)onEmailResult
{
if ([[MFMailComposeViewController class] canSendMail]) {
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"Game"];
// Set up recipients
NSArray * toRecipients = [NSArray arrayWithObject:@"[email protected]"];
[picker setToRecipients:toRecipients];
// Fill out the email body text
NSString * emailBody = [NSString stringWithFormat:@"My Score: %d/%d, My Time: %@", numberOfCorrectAnswer, [[[DataManager sharedInstance] questions] count], time];
[picker setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:picker animated:YES];
[picker release];
}
else {
NSString *recipients = @"mailto:[email protected]?&subject=Game";
NSString *body = [NSString stringWithFormat:@"&body=My Score: %d/%d, My Time: %@", numberOfCorrectAnswer, [[[DataManager sharedInstance] questions] count], time];
NSString *email = [NSString stringWithFormat:@"%@%@", recipients, body];
email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
}
}
只是在地址栏手动输入他们的电子邮件ID? – iNoob 2012-07-11 04:46:17
如果我将输入电子邮件ID manullay然后它会发送到应用程序或不 – user1495149 2012-07-11 04:49:27
Ofcourse它会发送,你为什么不尝试?请注意,它不适用于simualtor,您需要一个设置了邮件帐户的实际设备。 – iNoob 2012-07-11 04:51:10