【发布时间】:2013-03-27 15:46:51
【问题描述】:
以下是我在邮件中发送附件的代码。这工作正常。我可以发送邮件,但我并不总是收到邮件。
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];
}
【问题讨论】:
-
你在模拟器中测试吗?
-
附注 - 为什么要创建邮件撰写控制器然后检查邮件是否可以发送?如果您可以发送邮件,您应该只创建控制器并进行设置。
-
你说这段代码只在某些时候有效。然后你说你不能从应用程序发送邮件。它是哪一个?您有时可以从应用程序发送邮件,还是从不从应用程序发送邮件?
-
我可以一直发送邮件,但收不到邮件。我有时会收到邮件。
-
我已经更改了我的问题的内容,以便更清楚发生了什么
标签: ios mfmailcomposeviewcontroller mfmailcomposer