2009-03-08 3 views
0

사용자에게 이메일로 내용을 보내는 링크를 UIWebView에 만들고 싶습니다. 간단한 예는 다음과 같습니다href = mailto (iPhone)에서 문자를 이스케이프 처리하는 방법

<a href="mailto:[email protected]?subject=Sarcasm&body=I » 
<b>love</b> &lt;html&gt; mail!">Hi!</a> 

은 다음과 같습니다 메시지 생성 어떤 :

- 메시지 시작을 ---

사람 : [email protected] 제목 : 풍자

나는 메일이 좋아!

- 종료 메시지 -

은 좀 더 정교한 뭔가를해야합니다. 제목에는 공백이있는 여러 단어가 포함됩니다. 본문에는 HTML, list (<ul>) 및 href에 따옴표가있는 하이퍼 링크가 포함됩니다. 그런 것을 어떻게 만듭니 까? 여기

은 예입니다 :

대상 =

몸 "이 내용은 테스트입니다"= "이 몸의 일부인 다음 링크 목록은 다음과 같습니다.
<UL>
< 리 >가 < a href = "http://www.abc.com"> abc.com </li >
<li> <는 A HREF = "http://www.xyz.com"> xyz.com </A > </리 >
</UL >
끝입니다. "

또한 시뮬레이터는 mailto 링크를 클릭 할 때 어떤 작업을 수행합니까?

답변

2

시뮬레이터에는 Mail.app가 없으므로 홈 화면에서 볼 수 있으므로 mailto 링크가있을 때 열리지 않습니다.

내가 아는 한, mailto를 사용하여 HTML 형식의 전자 메일을 보내는 방법은 없습니다.

+0

포츈 쿠키 앱을 다운로드하십시오. – Garrett

+0

예제 앱에서이 내용을 보지 못했습니다. 어디에서 찾을 수 있습니까? – 4thSpace

+0

작동 방식 : http://davidebenini.it/2008/12/19/iphone-sdk-sending-formatted-email/ – 4thSpace

1

프로젝트에 대한 MessageUI.framework 참조가 필요합니다.

은 당신의하는 .m 파일에 다음과 같은 몇 가지 방법을 만들기 대리자 <MFMailComposeViewControllerDelegate>

를 추가하여 .H 파일

#import <MessageUI/MessageUI.h> 
#import <MessageUI/MFMailComposeViewController.h> 

에 다음을 추가합니다.에서 사용할 수 많은 지침에

-(IBAction)checkCanSendMail:(id)sender{ 
     Class mailClass = (NSClassFromString(@"MFMailComposeViewController")); 
     if (mailClass != nil) { 
      if ([mailClass canSendMail]) { 
       [self displayComposerSheet]; 
      } 
      else { 
       //Display alert for not compatible. Need iPhone OS 3.0 or greater. Or implement alternative method of sending email. 
      } 
     } 
     else { 
      //Display alert for not compatible. Need iPhone OS 3.0 or greater. Or implement alternative method of sending email. 
     } 
    } 

    -(void)displayComposerSheet { 
     MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init]; 
     mailer.mailComposeDelegate = self; 

     [mailer setSubject:@"Email Subject"]; 

     //Set our to address, cc and bcc 
     NSArray *toRecipients = [NSArray arrayWithObject:@"[email protected]"]; 
     //NSArray *ccRecipients = [NSArray arrayWithObjects:@"[email protected]",@"[email protected]",nil]; 
     //NSArray *bccRecipients = [NSArray arrayWithObjects:@"[email protected]",@"[email protected]",nil]; 

     [mailer setToRecipients:toRecipients]; 
     //[mailer setCcRecipients:ccRecipients]; 
     //[mailer setBccRecipients:bccRecipients]; 

     NSString *emailBody = @"\ 
     <html><head>\ 
     </head><body>\ 
     This is some HTML text\ 
     </body></html>"; 

     [mailer setMessageBody:emailBody isHTML:YES]; 

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

애플 샘플 코드 : http://developer.apple.com/iphone/library/samplecode/MailComposer/

나는이 웹보기를 사용하지 않는 알고 있지만 그것은 당신이 당신의 응용 프로그램 내에서 HTML 이메일을 만들 수 없습니다.

관련 문제