I was trying recycle code for saving an image and attaching it to an email, with no luck. After I get the three values out of the PeoplepickerNavigation controller I want to save them for use and place them as text into an email. All I get now is a placed image called "addresssend" in my email body, how would I extract the text from the "addresssend" file so that the user would see firstName, lastname, & address.
Here is the saving code:
- (IBAction)saveData {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *savedDataPath = [documentsDirectory stringByAppendingPathComponent:@"addresssend.txt"];
NSString *addresssend = lastName.text; // lastName is from the LastNameProperty
[addresssend writeToFile:savedDataPath atomically:NO];
}
Here is the retrieving code:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *appFile2 = [documentsDirectory stringByAppendingPathComponent:@"addresssend.txt"];
NSData *myData2 = [[[NSData alloc] initWithContentsOfFile:appFile2] autorelease];
[picker addAttachmentData:myData2 mimeType:@"text/txt" fileName:@"addresssend"];
I can see how this would just deposit the file, can anyone point me in the right direction so that the email body shows the actual name & address?
Thanks,
Michael