i have an app that need to send e-mail to constant e-mail address.
i used this code to send e-mail until now:
NSString *subject = [NSString stringWithFormat:@"%@ Login Info",self.name];
NSString *body = [NSString stringWithFormat:@"Username : %@ \n Password : %@ \n E-Mail : %@ \n Sequrity Question : %@ \n Sequrity Answer : %@" ,self.user,self.password,self.email,self.seqQuestion,self.seqAnswer];
NSLog(@"%@",body);
NSString *mailString = [NSString stringWithFormat:@"mailto:?to=%@&subject=%@&body=%@",
[to stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],
[subject stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],
[body stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:mailString]];
The problem came with this is when the user that used the app not defined an e-mail address in is iphone’ mail app so he can’t send the mail.
there is any other way for sendding e-mail to constant e-mail address?
Rather than creating a mailto: url link, why not use the SDK’s email/messaging system?
Check if the user can send an email first
If this returns NO, the user can’t send email. Perhaps show a message suggesting they might want to configure the email settings.
If they can send a message (ie email is configured), then compose and send the email
If you find the user can’t send an email in the first instance, you will either have to write your own service and connect to that (via a webservice, perhaps) or you will have to write your own implementation of the email protocol to connect to a known server with a known account.