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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…