2009-03-08 4 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>
<李>は、 < HREF = "http://www.abc.com"> abc.com </> < /リチウム>
<リチウム> < HREF = "http://www.xyz.com"> xyz.com </> < /リチウム>
</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/

私は、これはWebViewのを使用していません知っているが、それはあなたがあなたのアプリケーション内からHTMLメールを作成することができません。

関連する問題