objective c - How to send user entered details to email in iOS? -
i storing user details using post request ,my question whatever details user entered details should email id. how can ?
my code here :
- (ibaction)nextbutton:(id)sender { nslog(@"name:%@",nametextfield.text); nslog(@"emailid:%@",emailtextfield.text); nslog(@"phonenumber:%@",phonetextfield.text); nslog(@"pickupaddress:%@",addresstextfield.text); if([nametextfield.text isequaltostring:@""] || [emailtextfield.text isequaltostring:@""] || [phonetextfield.text isequaltostring:@""] || [addresstextfield.text isequaltostring:@""]) { uialertview* alertviewq = [[uialertview alloc] initwithtitle:@"alert" message:@"please enter details." delegate:self cancelbuttontitle:@"ok" otherbuttontitles:nil]; [alertviewq show]; } else { nsstring *post = [nsstring stringwithformat:@"&name=%@&emailid=%@&phonenumber=%@&pickupaddress=%@",nametextfield.text,emailtextfield.text,phonetextfield.text,addresstextfield.text]; nslog(@"post:%@",post); nsdata *postdata = [post datausingencoding:nsasciistringencoding allowlossyconversion:yes]; nsstring *postlength = [nsstring stringwithformat:@"%lu",(unsigned long)[postdata length]]; nsmutableurlrequest *request = [[nsmutableurlrequest alloc] init]; [request seturl:[nsurl urlwithstring:[nsstring stringwithformat:@"http://example.com/userdetails.php"]]]; [request sethttpmethod:@"post"]; [request setvalue:postlength forhttpheaderfield:@"content-length"]; [request setvalue:@"application/x-www-form-urlencoded" forhttpheaderfield:@"current-type"]; [request sethttpbody:postdata]; nsurlconnection *theconnection=[[nsurlconnection alloc] initwithrequest:request delegate:self]; if (theconnection) { } else { uialertview* alertview = [[uialertview alloc] initwithtitle:@"failed" message:@"check networking configuration." delegate:self cancelbuttontitle:@"ok" otherbuttontitles:nil]; [alertview show]; } } }
simple answer : cant within ios app.
solution : need setup email @ server side. whenever user sends request server can mail content form back-end. per knowledge, way achieve requirements.
i can assume url server uses php. please refer following link mail php server in back-end.
http://www.w3schools.com/php/func_mail_mail.asp
hope may you.
Comments
Post a Comment