Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MFMailComposeViewController canSendMail返回是,但不在iOS中发送邮件_Ios_Mfmailcomposeviewcontroller_Mfmailcomposer - Fatal编程技术网

MFMailComposeViewController canSendMail返回是,但不在iOS中发送邮件

MFMailComposeViewController canSendMail返回是,但不在iOS中发送邮件,ios,mfmailcomposeviewcontroller,mfmailcomposer,Ios,Mfmailcomposeviewcontroller,Mfmailcomposer,以下是我在邮件中发送附件的代码。这个很好用。我可以发送邮件,但我并不总是收到邮件 MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self; // Set the subject of email [picker setSubject:@"My data file"]; // Add email addresses [

以下是我在邮件中发送附件的代码。这个很好用。我可以发送邮件,但我并不总是收到邮件

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

// Set the subject of email
[picker setSubject:@"My data file"];

// Add email addresses

[picker setToRecipients:[NSArray arrayWithObjects:emailId, nil]];


// Fill out the email body text
NSString *emailBody = @"Hello, \n Please find the data from the iOS app in the attachments.\n\n Thank you.\nMy Team.";

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

// Create NSData object from file
NSData *exportFileData = [NSData dataWithContentsOfFile:filePath];

// Attach image data to the email
[picker addAttachmentData:exportFileData mimeType:@"text/csv" fileName:  [self.CSVNameTextField text]];


// Show email view

if ([MFMailComposeViewController canSendMail]) {

    [self presentModalViewController:picker animated:YES];
}

使用应用程序发送邮件后,转到iPhone上的邮件软件,您很可能会在发件箱中找到邮件


因为MFMailComposeViewController只会将邮件转发到邮件软件,它不关心邮件旁边会发生什么。因此,这取决于您的邮件软件如何以及何时更新发件箱。

我也有同样的问题,我发现它会通过邮箱,说它已发送,然后什么也不会通过

大约20-30分钟后,第一个邮件通过了,然后我发送的其他邮件也通过了

我不知道为什么要花这么长时间,如果我发现了,我会编辑这个答案,但肯定要等一个小时,然后再假设你的代码被破坏了


希望这能帮助像我这样可能一遍又一遍地搜索代码的人

在我的情况下,我必须手动打开iphone邮件应用程序,然后邮件立即发送和接收。

您是否在模拟器中进行测试?旁注-为什么要创建邮件撰写控制器,然后检查邮件是否可以发送?如果你可以发送邮件,你应该只创建控制器并设置它。你说这个代码有时才有效。然后你说你不能从应用发送邮件。是哪一个?你有时可以从应用程序发送邮件,还是从不从应用程序发送邮件?我可以一直发送邮件,但我没有收到邮件。我有时会收到邮件。我改变了问题的内容,以便更清楚地了解发生了什么事。你有没有找到更持久的解决办法?我也遇到了这个问题。电子邮件已排队,但(有时)未发送。这应该是一条评论