IOS: sending email with attachment automatically adds another attached file (.txt)

I use the following code to send email with the contents of an NSData object (with the variable name: data):

MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];

[controller setSubject:@"Subject"];
[controller addAttachmentData:data mimeType:@"application/pdf" fileName:@"Attachment"];
[controller setMessageBody:@"Please find attached the connections for..." isHTML:NO];

controller.mailComposeDelegate = self;
[self presentModalViewController:controller animated:YES];

It adds a UIView generated as a pdf as an attachment and sends an email. This is all good except for one problem:

When the email is received, along with the attached pdf, there is another attached .txt file, the contents of which are: "Sent from my iPad." If I don’t attach the pdf, the message "Sent from my iPad" appears in the body of the message, and not in the attached file.

Does anyone know how to solve this? I do not want the text file to be attached in the message.

Hi,

Peter

+5
source
1

, , / , Base64, ! ...

Content-Type: multipart/mixed;
    boundary="_003_81E0DB72B1F643FBAA40D9BCB66A11E4_"

--_003_81E0DB72B1F643FBAA40D9BCB66A11E4_
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64

SGkgTW9tIQ==

( "Hi Mom!" Base64)

--_003_81E0DB72B1F643FBAA40D9BCB66A11E4_
Content-Type: application/octet-stream; name="MyAttachment.xlsx"
Content-Description: MyAttachment.xlsx
Content-Disposition: attachment; filename="MyAttachment.xlsx"; size=15262
Content-Transfer-Encoding: base64

UEsDBBQABgAIAAAAIQA3Mb2RgAEAAIQFAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAAC

AF81AABkb2NQcm9wcy9hcHAueG1sUEsFBgAAAAANAA0AaAMAACA4AAAAAA==

--_003_81E0DB72B1F643FBAA40D9BCB66A11E4_

Content-Type: text/html; name="ATT00001.htm"
Content-Description: ATT00001.htm
Content-Disposition: attachment; filename="ATT00001.htm"; size=91
Content-Transfer-Encoding: base64

PGh0bWw+PGJvZHkgYmdjb2xvcj0iI0ZGRkZGRiI+PGRpdj48L2Rpdj48ZGl2Pjxicj48YnI+U2VudCBmcm9tIG15IGlQYWQ8L2Rpdj48L2JvZHk+PC9odG1sPg==

( <html><body bgcolor="#FFFFFF"><div></div><div><br><br>Sent from my iPad</div></body></html> Base64)

--_003_81E0DB72B1F643FBAA40D9BCB66A11E4_--

→ , , , HTML.

, , , Apple . , showstopper, / , , , MFMailComposeViewController , . , .:)

+4

All Articles