views:

77

answers:

1

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

A: 

Do a search for MFMailComposeViewController and take a look as some of the tutorials. You've asked a bunch of related questions that could be answered by doing a Google search for the component.

MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:@"My Subject"];
[controller setMessageBody:@"Hello there." isHTML:NO]; 
[self presentModalViewController:controller animated:YES];
[controller release];
Jordan
Thanks, the retrieving code is within the MFMailViewController, however it's just bringing up the file..I'm looking for the contents of the file to be displayed.
Michael Robinson
Thanks for the guidance
Michael Robinson