ios - MFMailComposeViewController canSendMail 返回 YES 但不在 iOS 中发送邮件

标签 ios mfmailcomposeviewcontroller mfmailcomposer

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

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 只会将 Mail 转发给 Mail-Software,它并不关心消息接下来会发生什么。因此,发件箱更新的方式和时间取决于您的邮件软件。

关于ios - MFMailComposeViewController canSendMail 返回 YES 但不在 iOS 中发送邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15663121/

相关文章:

ios - 将 UIDatePicker 用于公历以外的日历

ios - 应用内电子邮件发出嗖嗖声但不发送

安卓 : how to open a mail composer view?

iphone - IOS 自定义图标电子邮件附件

ios - 如何在 iOS 中向超过 2000 个收件人发送邮件?

ios - 如何读取一个像素?像素坐标如何在 iPhone 上工作?

ios - 弹出式 UIViewController

ios - 如何在不打电话的情况下从另一个应用程序中打开电话应用程序?

ios - 取消 MFMailComposeViewController 会导致内存泄漏?

iphone - cocos2d MFMailComposeViewController