“addAttachmentData:” to add any types of files as an attachment. .. a NSData object for that file, followed by nailing down the MIME type. achmentData Method public virtual Void AddAttachmentData (NSData attachment, String mimeType, String fileName ). The MFMailComposeViewController has the delegate method addAttachmentData:mimeType: fileName: that you can use to add attachment data to the.

Author: Zulkizil Groll
Country: Romania
Language: English (Spanish)
Genre: Relationship
Published (Last): 16 December 2013
Pages: 155
PDF File Size: 18.49 Mb
ePub File Size: 2.7 Mb
ISBN: 454-6-37935-486-1
Downloads: 76810
Price: Free* [*Free Regsitration Required]
Uploader: Vudokasa

One last thing before we can test: Xcode Project Template with a pre-built Storyboard. Compile and run the app. When Mail or some other app wants to send your app a file, it does so via one of two methods: Should you need a code in Objective-C syntax, that really shouldn’t be hard to achieve.

The way you do this on iOS is by registering your app as able to handle certain UTIsand exporting any UTIs that are not already known by the system. You can download this amazing app aedattachmentdata app store totally free of cost!

Email Tutorial for iOS: How To Import and Export App Data Via Email in your iOS App

Lastly, we invoke the addAttachmentData method to attach the file. Since Swift is presently the hottest language for iOS apps development, I will provide the implementation in it.

Hope this post will help you. Line of the above code define the email subject, message content and recipients.

ios – Attaching .txt to MFMailComposeViewController – Stack Overflow

As I was mentioning above, the app allows you to share multiple media files which includes image and video files through an email. You can save and view signature creation as an image or a video.


The app simply displays a list of files in a plain table view. If you have any suggestion for the iOS Programming series, feel free to let us know. If you have any further questions, please do not hesitate to contact me. A year ago, we wrote a short tutorial to show you how to send email using MessageUI framework.

As always, leave us comment and share your thought about the tutorial. A lot of developers want to be able to share their app data via email. Intro to Object Addattach,entdata Programming. This app allows you to make and save multiple signatures. So the next thing we need to do is set up our Info.

iOS – Add multiple attachments to an email (Swift 2.3)

These addaattachmentdata are stored in the documents directory. To save you from creating the Xcode project from scratch, you can download this project template to begin the development. Luckily, this is pretty easy to do on the iPhone — you just have to set a few keys in your Info.

NSLog “Mail saved”. The demo app should display a list of files in the main view. You can test it out by emailing yourself a copy of this sample bug if you want:.

iOS – Add multiple attachments to an email (Swift )

The project template comes with:. Author simonng Simon Ng. In the meantime, let me know if you have any questions or comments — and what bugs you think are the scariest! Demo App for email attachment. Line 7 creates the built-in MFMailComposeViewController, which provides the standard user interface for managing the editing and sending of an email message. As the primary focus is to demonstrate the attachment addattachmentadta, we keep the demo app very simple.


In the above code, filePaths is a addattachmenteata of full local file path. If the user addattachmentdzta via email, we use a MFMailComposeViewController to create an email message, and we add ad attachment with our bug data to the message. NSLog “Mail sent”. As it is evident from above code, you can combine multiple file paths into an array and then iterate over this collection and call the following method with NSData object. To understand what happens when, Oliver Drobnick has put together a very handy article with diagrams on what gets called when.

NSLog “Mail sent failure: You can find more information about this app on mimetypr other post specifically dedicated to description of this app. Some asked how to attach a photo, PDF document or Powerpoint in the email.

mimety;e Then compile and run your app, and you should be able to automatically export a scary bug from your app via email! Here we modify the export button to prompt the user whether they want to export via File Sharing as before, or via email.