View Full Version : Email Data

Nov 6, 2008, 12:46 PM
I have an application,
It auto rotates,
It has a UITextView,
It has a UINavigationBar,
It has a UIBarButtonItem,

The UIBarButtonItem is linked to a function which is:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto:email@email.com?subject=Text&body=Text"]];

However I want the body of the email to be the contents on the UITextView but dont have a clue how to do this,

can i do it with the same function as this now or do i have to use a different function?


also i would like to know how to make the UINavigationBar thin when the application is auto rotated

Nov 7, 2008, 04:07 AM
You can access the content of a UITextView via its text property (docs: https://developer.apple.com/iphone/library/documentation/UIKit/Reference/UITextView_Class/Reference/UITextView.html) i.e.:

NSString *body = textView.text;

Before you can put it in a mailto to link, you need to escape it, i.e.:

body = [body stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]

And then you can simply construct the mailto link and insert it into the line of code you provided:

NSString *mailto = [NSString stringWithFormat:@"mailto:email@email.com?subject=Text&body=%@", body];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:mailto]];

Nov 7, 2008, 08:12 AM
thanks alot works great!! :)

anyone know how to make the navigation bar thin?