0

我正在使用 MFMailComposer。我向 gmail 发送电子邮件,MFMailComposer 返回 MFMailComposeResultSent 状态。但我没有收到任何电子邮件。我用 4.3.4 在 iphone4 上进行了测试。我做错了什么?

MFMailComposeViewController *mailPicker = [[MFMailComposeViewController alloc] init];
    mailPicker.mailComposeDelegate = self;

    // Set the subject of email
    [mailPicker setSubject:@"Subject"];
    NSString *emailBody = @"Hello from ios";

    // This is not an HTML formatted email
    [mailPicker setMessageBody:emailBody isHTML:NO];


    [self presentModalViewController:mailPicker animated:YES];

    [mailPicker release];


- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
    if (result == MFMailComposeResultFailed) 
 {
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:[error description] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alertView show];
    [alertView release];
 }
if (result == MFMailComposeResultSent)
 {
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Success" message:@"Message has been sent" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alertView show];
    [alertView release];
 }
else
 {
    [self dismissModalViewControllerAnimated:YES];
 }
}

编辑:我在控制台中找到了这个:

DA|Could not open the lock file at /tmp/DAAccountsLoading.lock. We'll load the accounts anyway, but bad things may happen

EDIT2:在带有 4.3.4 的 iPhone4 上不起作用,但在带有 4.3 的 ipod 上工作正常。

4

2 回答 2

2

你没有做错任何事。从 Apple 的网站检查这一行:

MFMailComposeResultSent– 电子邮件在用户的发件箱中排队。它已准备好在用户下次连接到电子邮件时发送。

于 2012-10-07T07:29:50.417 回答
0

不要在指定位置释放邮件选择器[mailPicker release]; .. 尝试使用 Autorelease 方法

MFMailComposeViewController *mailPicker = [[[MFMailComposeViewController alloc] init]autorelease];

其余的都很好。

于 2011-11-24T12:41:57.300 回答