-1

I'm working on an app but I need one last thing. I would like to send an in-app mail with the data from several textfields. I store the data like this:

 //1e savestring
NSString *saveString59 = field1.text;
NSUserDefaults *defaults59 = [NSUserDefaults standardUserDefaults];
[defaults59 setObject:saveString59 forKey:@"saveString59"];
[defaults59 synchronize];

and I display it like this:

//First load string
NSUserDefaults *defaults59 = [NSUserDefaults standardUserDefaults];
NSString *loadString59 = [defaults59 objectForKey:@"saveString59"];
[field1 setText:loadString59];
[loaded setText:@"Data Loaded Successfully" ];

I would like to display this in my email in a particular way. It's a tennis app and each player has some aces and some first serves.

Can I display the data in-mail like this?

Name of player (textfield1)

Aces: "data" (textfield2) First serves: "data" (textfield3) Seconds serves: "data" etc...

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Sam VG
  • 143
  • 1
  • 2
  • 9

2 Answers2

1

I recommend using MFMailComposeViewController with an HTML formatted body. To get your textfield data into the body you can use something similar to this:

MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
NSString *emailBody = [NSString stringWithFormat:@"<p>Name of player %@</p>", self.textField1.text];                          
[mail setMessageBody:emailBody isHTML:YES];
  • Thnx for your help, but you give me the possibility of adding 1 textfield data to my mail, but I need about 15 textfield data added to my mail... – Sam VG Jan 29 '14 at 19:15
  • To achieve this you can add them all to the NSString with the stringWithFormat function like this: [NSString stringWithFormat:@"

    Name of player %@

    Aces: %@

    ", self.textField1.text, self.textField2.text]. For better readability I would suggest to use an NSMutableString and use the appendFormat function.
    – Fabian Kröger Jan 29 '14 at 20:23
-1

Use MFMailComposeViewController. See this answer for more help.

Edit: Reference doc for this class can help you too: https://developer.apple.com/library/ios/documentation/MessageUI/Reference/MFMailComposeViewController_class/Reference/Reference.html

HTH.

Community
  • 1
  • 1
Foriger
  • 459
  • 5
  • 30