Yes it wont work becuase you have to give the complete path to access that file , which you are trying to attach, like in your example:
NSString *fileName = [NSString stringWithFormat:@"%@/textfile.txt",
documentsDirectory];
this is the full path of the textfile.txt with document directory path as well. That is the reason you are not getting attachment correctly. YOu have to give full path to that file which you are trying to attach.