ios - Creating and attaching a .txt file to email in Xcode -


i want make ios app makes/creates text file (.txt) sends email.

the issue having data encrypted pops error "use of undeclared identifier"

[mailcontroller addattachmentdata:datatobeencrypted mimetype:@"text/plain"

here .m file

// //  fileioviewcontroller.m //  fileio // //  created flare gun on 6/24/14. //  copyright (c) 2014 flaregunapplications. rights reserved. //  #import "fileioviewcontroller.h"  @interface fileioviewcontroller ()  @end  @implementation fileioviewcontroller  - (void)viewdidload  {     [super viewdidload];     // additional setup after loading view, typically nib. }  - (void)didreceivememorywarning {     [super didreceivememorywarning];     // dispose of resources can recreated. }  -(void) writetotextfile{     //get documents directory:     nsarray *paths = nssearchpathfordirectoriesindomains     (nsdocumentdirectory, nsuserdomainmask, yes);     nsstring *documentsdirectory = [paths objectatindex:0];      //make file name write data using documents directory:     nsstring *filename = [nsstring stringwithformat:@"%@/textfile.txt",                           documentsdirectory];     //create content - 4 lines of text     nsstring *content = @"one\ntwo\nthree\nfour\nfive";     //save content documents directory     [content writetofile:filename               atomically:no                 encoding:nsstringencodingconversionallowlossy                    error:nil];      if([mfmailcomposeviewcontroller cansendmail]) {         mfmailcomposeviewcontroller *mailcontroller = [[mfmailcomposeviewcontroller alloc] init];         mailcontroller.mailcomposedelegate =self;         [mailcontroller setsubject:@"records"];         [mailcontroller setmessagebody:@"" ishtml:yes];         [mailcontroller addattachmentdata:datatobeencrypted mimetype:@"text/plain" filename:@"records.txt"];         [self presentmodalviewcontroller:mailcontroller animated:yes];         [mailcontroller release];     } else {         //pop notification         uialertview *alert = [[uialertview alloc] initwithtitle:@"error" message:@"could not send email. verify internet conneciton , try again." delegate:nil cancelbuttontitle:@"done" otherbuttontitles:nil];         [alert show];         [alert release];     }  }  @end 

to declare datatobeencrypted use like:

nsdata *datatobeencrypted = [nsdata datawithcontentsoffile:filename]; 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -