i want to send the mail from iphone within my application
I am using开发者_运维百科 the following code to send the mail but when i click on the send button, it come out of the app and send the mail. i dont want to come out of my application.
-(IBAction) done:(id) sender
{
[self sendEmailTo: @"uttam.beldar@yahoo.com" withSubject: @" Question"
withBody:[textbody text]];
}
- (void) sendEmailTo:(NSString *)to withSubject:(NSString *) subject withBody:(NSString *)body
{
NSString *mailString = [NSString stringWithFormat:@"mailto:?to=%@&subject=%@&body=%@",
[to stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],
[subject stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],
[body stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:mailString]];
}
can any one have the solution for this ?
You probably want to look into MFMailComposeViewController - it's the best option for that after the release of iPhone OS 3.0 software.
If you don't want a UI, you need to implement the SMTP protocol, since I don't think there's a built in one. But there is a google code project that provides this, if you want to incorporate it in your app.
You can implement send mail in this easy way.
Tell me if you have problems.
A
精彩评论