Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

cabrown

macrumors regular
Original poster
Anyone how to go about putting the text from a label into the body of an email? I know how to create an email that can be sent on a button touch but I am not sure how to put the label text in the body of the email. My label is randomly populated from a plist file and the view is populated by
Code:
TestAppDelegate *appDelegate =  
    (TestAppDelegate *)[[UIApplication sharedApplication] delegate];  
    
	
	fileContents = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"plist"];
	
	NSDictionary *test = [[NSDictionary alloc] initWithContentsOfFile:fileContents];
	
	NSMutableArray *things = [test valueForKey:@"things"];
		
		[UIView beginAnimations:nil context:NULL];
		[UIView setAnimationDuration:1.0];
		[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:label cache:YES];
		[UIView commitAnimations];
		
	int randomNumber = arc4random() % [things count];
	things = [things objectAtIndex:randomNumber];
	[appDelegate setModelData:things];
I already know how to set up an email I just don't know what to place in for the body text that would set it as the current displaying label.
 
Code:
// Get the content of your label.
NSString *body = yourLabel.text;

// Percent escaping.
NSString *subject = [@"Your Subject" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *body = [body stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

// Construct mailto URL.
NSString *url = [NSString stringWithFormat:@"mailto:?subject=%@&body=%@", subject, body];

// Open Mail.app.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.