IOS How to open mail application
These URLs launch Mail and open the compose message controller:
NSString *stringURL = @"mailto:test@example.com"; NSURL *url = [NSURL URLWithString:stringURL]; [[UIApplication sharedApplication] openURL:url];
You can also provide more information, for a customized subject and body texts:
NSString *subject = @"Message subject"; NSString *body = @"Message body"; NSString *address = @"test1@akosma.com"; NSString *cc = @"test2@akosma.com"; NSString *path = [NSString stringWithFormat:@"mailto:%@?cc=%@&subject=%@&body=%@", address, cc, subject, body]; NSURL *url = [NSURL URLWithString:[path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; [[UIApplication sharedApplication] openURL:url];
You might also omit some information:
NSString *subject = @"Message subject"; NSString *path = [NSString stringWithFormat:@"mailto:?subject=%@", subject]; NSURL *url = [NSURL URLWithString:[path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; [[UIApplication sharedApplication] openURL:url];
Comments
Post a Comment