A client of mine is having an issue where he'll use our app to send an email with an auto generated PDF that's attached to the email and sometimes it will work and sometimes it will not.
Things We've noticed:
- When sending from his gmail account, it typically fails and the email is sent out with a blank message and an attachment that reads 'noname'.
- Sometimes, when selecting his personal email, the app still sends the email from his gmail account. I was able to reproduce this on an iPad Pro and can verify that when I select one email, it shows it was sent from another.
- Removing the gmail account from the iPad and readding it back usually fixes the problem for the first email sent and then it goes back to the normal problem stated in the first bullet.
Here is the code where I create the MailComposer view:
func configureMailComposeViewController() -> MFMailComposeViewController {
let mailComposerViewController = MFMailComposeViewController()
mailComposerViewController.mailComposeDelegate = self
if let fileData = NSData(contentsOfFile: GeneratePDF.attachEachPage()) {
mailComposerViewController.setSubject(Constants.EmailPreferences.subject)
mailComposerViewController.setMessageBody(Constants.EmailPreferences.message, isHTML: true)
mailComposerViewController.addAttachmentData(fileData, mimeType: "application/pdf", fileName: "overview")
}
return mailComposerViewController
}
The view opens up no problem, There's a title, body message, and an attachment. Yet, when received everything's been stripped except the title. The PDF is < 6MB and only has 5 pages.