I want to send email with a PDF attachment. I created PDF file, then I did the following which is wrong I believe:
// locate folder containing pdf file
let documentsPath = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)[0] as! String
let pdfFileName = documentsPath.stringByAppendingPathComponent("chart.pdf")
let fileData = NSData(contentsOfFile: pdfFileName)
mc.addAttachmentData(fileData, mimeType: "pdf", fileName: chart)
Before sending the email, I can see attached chart.pdf
, but when I sent the email, it was sent without attachment and this is because I didn't attached correctly the file.