2011-10-14 57 views
0

可以打開Iphone郵件應用程序而無需撰寫新消息?Iphone郵件應用程序

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"mailto:%@?subject=My Subject", _recipient]]]; 

此代碼不適合我。

我只需要在主屏幕上打開郵件應用程序。

感謝

PS對不起,我的英文))

+0

試試這個 - [此處輸入鏈接的描述] [1] [1]:HTTP ://stackoverflow.com/questions/5244754/iphone-native-email-client-ui/5244773#5244773 – iOSPawan

回答

1
-(void) EmailMethod 
    { 
    MFMailComposeViewController *picker=[[MFMailComposeViewController alloc]init]; 
picker.mailComposeDelegate = self; 
    [picker setToRecipients:@"[email protected]"]; 
[picker setSubject:@"Place your subject of mail here."]; 
[picker setMessageBody:@"Place your body of mail here." isHTML:YES]; 
    [self presentModalViewController:picker animated:YES];  
    } 

    - (void)mailComposeController:(MFMailComposeViewController*)controller 
      didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{ 
    switch (result) 
    { 
    case MFMailComposeResultCancelled: 
     UIAlertView *ErrorAlert = [[UIAlertView alloc] initWithTitle:@"Canceled !!" 
         message:@"Mail sending cancelled." delegate:nil 
         cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; 
     [ErrorAlert show]; 
     [ErrorAlert release]; 
     break; 
    case MFMailComposeResultSaved: 
     UIAlertView *ErrorAlert = [[UIAlertView alloc] initWithTitle:@"Saved" 
            message:@"Mail saved to Drafts." delegate:nil 
            cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; 
     [ErrorAlert show]; 
     [ErrorAlert release]; 
     break; 
    case MFMailComposeResultSent: 
     UIAlertView *ErrorAlert = [[UIAlertView alloc] initWithTitle:@"Email Sent" 
        message:@"Thank you for recommending us to your friends via Email." 
        delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; 
     [ErrorAlert show]; 
     [ErrorAlert release]; 
     break; 
    case MFMailComposeResultFailed: 
     UIAlertView *ErrorAlert = [[UIAlertView alloc] initWithTitle:@"Error !!" 
            message:@"Failed to send mail." delegate:nil 
            cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; 
     [ErrorAlert show]; 
     [ErrorAlert release]; 
     break; 
    default: 
     UIAlertView *ErrorAlert = [[UIAlertView alloc] initWithTitle:@"Error !!" 
            message:@"Failed to send mail." delegate:nil 
            cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; 
     [ErrorAlert show]; 
     [ErrorAlert release]; 
     break; 
} 
[self becomeFirstResponder]; 
[self dismissModalViewControllerAnimated:YES]; 

}

相關問題