-1

这是我的 html 内容,我有一个按钮,单击按钮我必须发送邮件,但邮件的内容(如 body 、subject )将从 html 内容中获取。

html内容:

@"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />
<title>Untitled Document</title>
<style>.reservation { }.reservation table {}.reservation tr { background-color: #F6F2E7; }.reservation th { font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; color: #F6F2E7; background-color: #302824; padding: 5px; text-align:left; }.reservation td { padding-top: 3px; padding-right: 5px; padding-bottom: 3px; padding-left: 5px; border-bottom: 1px solid #DFDBD1; color: #443D37; font-family: Arial, Helvetica, sans-serif; font-size: 12px; }.reservation td strong { font-weight: bold; padding-right:10px; }.reservation td span { font-weight: normal; }
</style>
</head>
<body>
<div style=\"width:300px; margin:auto;\"><div class=\"reservation\">  
<table width=\"300px\" cellpadding=\"0\" cellspacing=\"0\">  
<tr>   <th width=\"130px\">Reservation </th>  
<th> </th> </tr>   
<tr> <td>     <strong>%@ :</strong>  </td> 
<td>  <span>%@</span>        </td>    
</tr>  <tr> <td>     <strong>%@ :</strong>  </td> 
<td>  <span>%@</span>        </td>    </tr>   
<tr> <td>     <strong>%@ :</strong>  </td> <td> <span>%@</span>        </td>    </tr>    
<tr> <td>     <strong>%@ :</strong> </td> 
<td>   <span>%@</span>        </td>    </tr>  
</table>
</div>
</div>
</body>
</html>
4

3 回答 3

3

据我所知,android 不直接支持 HTML 内容的此类 CSS 标签。它支持带有 phonegap 的 CSS。

它只支持几个 HTML 标签,它们是:

<a> (supports attribute "href")
<b>
<big>
<blockquote>
<br>
<cite>
<dfn>
<div>
<em>
<font> (supports attributes "color" and "face")
<i>
<img> (supports attribute "src". Note: you have to include an ImageGetter to handle retrieving a Drawable for this tag)
<p>
<small>
<strong>
<sub>
<sup>
<tt>
<u>

要在代码中使用 HTML,您可以使用Html.fromHtml("html data").

于 2012-10-30T05:17:38.870 回答
0

在邮件中发送 Html 内容你必须使用Html.fromHtml("html data").

这里的示例代码..

final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
        emailIntent.setType("text/html");
        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, 
            emailTo);
        emailIntent.putExtra(android.content.Intent.EXTRA_CC, 
                emailCc);
        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, 
                Html.fromHtml(subject));
        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, 
                Html.fromHtml(emailText));

   this.startActivity(Intent.createChooser(emailIntent, "email"));

AppMobiGurmeet 说得对。Android 只支持一些 Tag..

有关更多信息,请查看以下链接..

链接1

链接2

于 2012-10-30T05:09:45.797 回答
0

使用 HTML 标记并分配到字符串中。并Html.fromHtml(body)用于访问。

String body= first_name
                    + " "
                    + last_name
                    + " sent a message using ."
                    + "<br><br><br>Submitted on :" + date + " "+ time + "<br>"
                    + "Submitted by user:"+ first_name + " " + last_name + "<br>"
                    + "Address :" + Address + "<br>"
                    + "Contact No :"+ mobile + "<br>"

                    + "Comments :" + comment;


            Intent email = new Intent(Intent.ACTION_SEND);
            email.putExtra(Intent.EXTRA_EMAIL,
                    new String[] { "emailID"});



            email.putExtra(Intent.EXTRA_SUBJECT,
                    "Form submission from:");
            email.putExtra(Intent.EXTRA_TEXT,Html.fromHtml(body));
            email.setType("message/rfc822");

            startActivityForResult(
                    Intent.createChooser(email, "Choose an Email client :"),
                    MY_REQUEST_CODE);
于 2012-10-30T06:26:47.880 回答