Nik*_*Nik 4 ios mfmailcomposer mfmailcomposeviewcontroller
以下是我在邮件中发送附件的代码.这很好用.我能够发送邮件,但我并不总是收到邮件.
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];
}
Run Code Online (Sandbox Code Playgroud)
使用应用程序发送邮件后,转到iPhone上的Mail-Software,您很可能会在发件箱中找到邮件.
因为MFMailComposeViewController只会将邮件转发到邮件软件,它不关心邮件旁边会发生什么.因此,您的邮件软件将如何以及何时更新发件箱.
| 归档时间: |
|
| 查看次数: |
3694 次 |
| 最近记录: |