2010-01-13 102 views

回答

16

:)是的,你可以這樣做:

MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init]; 
composer.mailComposeDelegate = self; 
[composer setSubject:subject]; 
[composer setMessageBody:message isHTML:YES];      

其中,消息是隻是HTML內容的一個NSString。在裏面你可以添加你想要的所有HTML。

4

使用setMessageBody:isHTML:並傳遞正文中的正確HTML鏈接(<a href="your_url">your link text</a>),並將YES傳遞給isHTML參數。

4

你試過對你的代碼的建議嗎?我在進入這個網站之前試過了,很抱歉地說,它根本不起作用。鏈接看起來真的是藍色的,HTML被讀爲html,但沒有鏈接是可能的。當我點擊鏈接,我可以編輯它......

有什麼更好的建議嗎?

+0

您是否點擊了收到的電子郵件或編輯模式? – AsifHabib 2014-06-17 07:38:17

26

我刪除了我以前的答案,因爲它是不正確的和不相關的。經過多次拉動我終於找出了我的情況是怎麼回事,可能是在這個問題上發生了什麼。

當您爲MFMailComposeViewController撰寫HTML正文時,您必須必須在HTML中放入換行符。如果有任何線爲> 76個字符長,身體會作如下解釋:

Content-Type: text/html; charset=UTF-8 
Content-Transfer-Encoding: quoted-printable 

如果你把換行符,該Content-Transfer-Encoding: quoted-printable不會發生,一切都按預期工作。假設你有正確的HTML。

作爲一個例子,構建體,如下所示:

NSMutableString *body = [NSMutableString string]; 
// add HTML before the link here with line breaks (\n) 
[body appendString:@"<h1>Hello User!</h1>\n"]; 
[body appendString:@"<a href=\"http://www.mysite.com/path/to/link\">Click Me!</a>\n"]; 
[body appendString:@"<div>Thanks much!</div>\n"]; 

乾杯!

+1

優秀!高興地瞭解換行!,節省了我一些時間男士的歡呼 – MaKo 2011-09-25 11:50:33

7

我有同樣的問題。

我的鏈接是HTML,我可以看到'藍色',但如果我點擊它,不會打開safari mobile。允許我編輯文本。

在一類我有這樣的:

-(id) init{ 
    self = [super init]; 
    if (self) { 
      if ([MFMailComposeViewController canSendMail]) { 
       self.mailComposeDelegate = self; 
       [self setSubject: @"Subject"]; 
       [self setMessageBody: @"<h2>Body</h2><a href='http://www.google.com'>link example</a>" isHTML: YES]; 
      } 
      else { 
       UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Mail Accounts" 
                   message:@"You don't have a Mail account configured, please configure to send email." 
                   delegate:nil 
                 cancelButtonTitle:@"OK" 
                 otherButtonTitles: nil]; 
       [alert show]; 
      } 
    } 
    return self; 
} 

-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error{ 
    [controller dismissModalViewControllerAnimated: YES]; 
} 

在這裏你可以看到iPad的屏幕截圖: iPad Screen shot

如果我送的,然後我去「已發送」郵箱鏈接的作品,所以我認爲問題是打開鏈接的事件。

謝謝。

+0

你點擊了嗎?你有鏈接,如果是的話,那麼請在這裏張貼@Oceanicsix謝謝 – Maul 2013-12-25 10:22:56

+0

嗨,這是一年多以前,如果我現在誠實,我不記得我是如何完成這個問題的。抱歉,祝你好運! – Mikel 2013-12-25 20:50:09

相關問題