2012-01-04 39 views
0

我正在使用MessageUI框架發送電子郵件,但發送時我從未收到該電子郵件。未收到使用MessageUI框架發送的電子郵件

我進口#import <MessageUI/MessageUI.h>

,然後我有以下代碼

- (void)emailFile 
{ 
if(![MFMailComposeViewController canSendMail]) { 
    UIAlertView *cantSend = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Device not configured to send email" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil]; 
     [cantSend show]; 
    [cantSend release]; 
} else { 
    MFMailComposeViewController *mailView = [[[MFMailComposeViewController alloc] init] autorelease]; 
    mailView.mailComposeDelegate = self; 
    [mailView setToRecipients:[NSArray arrayWithObject:@"[email protected]"]]; 
    [mailView setSubject:@"Test"]; 
    [mailView setMessageBody:@"This is a text message" isHTML:NO]; 
    [self presentModalViewController:mailView animated:YES]; 
} 
} 

- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error 
{ 
if(error) { 
    UIAlertView *errorView = [[UIAlertView alloc] initWithTitle:@"Mail Error" message:[error localizedDescription] delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil]; 
    [errorView show]; 
    [errorView release]; 
} else { 
    switch (result) { 
     case MFMailComposeResultSent: 
      NSLog(@"Sent Mail"); 
      break; 
     case MFMailComposeResultSaved: 
      NSLog(@"Mail Saved"); 
      break; 
     case MFMailComposeResultCancelled: 
      NSLog(@"Mail Cancelled"); 
      break; 
     case MFMailComposeResultFailed: 
      NSLog(@"Mail Failed"); 
      break; 
     default: 
      break; 
    } 
} 
[controller dismissModalViewControllerAnimated:YES]; 
} 

我在控制檯中「已發送郵件」的消息,但我想我說我從未收到我發送的電子郵件。

我已經通過了蘋果的文檔不見了,找不到任何有助於任何人都可以幫我請。我是我做錯了什麼?

+0

您是否檢查過您正在使用的電子郵件的發件箱? – 2012-01-05 10:49:29

回答

3

確保您在設備上測試,電子郵件不會通過模擬器發送。

+0

我正在使用模擬器,我將不得不從測試部門獲取測試手機。謝謝你的幫助。 – Popeye 2012-01-04 14:44:25

相關問題