下面是我在邮件中发送附件的代码。这可以很好地工作。我可以发送邮件,但我并不总是收到邮件。
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];
}发布于 2013-03-28 00:06:29
在你用你的应用程序发送邮件后,去你的iPhone上的邮件软件,你很可能会在发件箱中找到邮件。
因为MFMailComposeViewController只会将邮件转发到邮件软件,而不关心邮件的下一步会发生什么。因此,这取决于您的邮件软件如何以及何时更新发件箱。
发布于 2014-06-03 14:40:04
我也有同样的问题,我发现它会穿过邮箱,说它已经寄出了,然后什么也不能通过。
大约20-30分钟后,第一封邮件通过了,然后逐渐地,我发送的其他邮件也通过了。
我不知道为什么花了这么长时间,如果我发现我会编辑这个答案,但一定要等上一个小时,然后再假设你的代码是坏的。
我希望这对像我这样一遍又一遍地搜索代码的人有所帮助
发布于 2016-12-14 14:17:34
在我的例子中,我不得不手动打开iphone邮件应用程序,然后邮件就会立即发送和接收。
https://stackoverflow.com/questions/15663121
复制相似问题