如何发送电子邮件URL

时间:2012-04-23 08:49:07

标签: iphone url

如何从包含“&”的iphone应用程序发送电子邮件地址在里面。 这是示例网址

http://www.google.co.in/search?hl=en&safe=active&q=facebook&oq=facebook&aq=f&aqi=&aql=&gs_l=mobile-gws-serp.3...0l0l0l1620716l0l0l0l0l0l0l0l0ll0l0.frgbld.&mvs=0

2 个答案:

答案 0 :(得分:0)

试试这个:在MFMailComposure iN中的电子邮件功能

-(void)displayComposerSheet
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"My URL!"];

// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:@"xyz@abc.com"];
NSString *emailBody = @"http://www.google.co.in/search?hl=en&safe=active&q=facebook&oq=facebook&aq=f&aqi=&aql=&gs_l=mobile-gws-serp.3...0l0l0l1620716l0l0l0l0l0l0l0l0ll0l0.frgbld.&mvs=0";
[picker setMessageBody:emailBody isHTML:NO];

[self presentModalViewController:picker animated:YES];
[picker release];
}

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
message.hidden = NO;

switch (result)
{
case MFMailComposeResultCancelled:
message.text = @" Message canceled";
break;
case MFMailComposeResultSaved:
message.text = @"Message saved";
break;
case MFMailComposeResultSent:
message.text = @"Message sent";
break;
case MFMailComposeResultFailed:
message.text = @"Message failed";
break;
default:
message.text = @"Message not sent";
break;
}
[self dismissModalViewControllerAnimated:YES];
}

答案 1 :(得分:0)

        CFStringRef escaped = 
        CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
                                                (CFStringRef)theURL,
                                                NULL,
                                                (CFStringRef)@"!*'();:@&=+$,/?%#[]",
                                                kCFStringEncodingUTF8);

                    NSString* useit = (NSString*)escaped;

不要忘记发布CGStringRef