2013-04-04 15 views
0

在我的應用程序中,我有一個選項可以通過電子郵件發送文件的URL,並且在除nexus 7(OS版本4.2 .2)。當來自nexus 7的郵件時,收件人只能得到一個文本。我已經搜索了很多解決方案並找不到任何解決方案。 以下是我的代碼電子郵件鏈接似乎只是來自Nexus 7(操作系統版本:4.2.2)的文本

public static boolean sendEmailLink(Context context, String[] emailTo, String[] emailCC, String[] emailBCC, String subject, String emailBody, String notification) throws ActivityNotFoundException { 

    final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 

    emailIntent.setType("message/rfc822"); 

    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, emailTo); 

    emailIntent.putExtra(android.content.Intent.EXTRA_CC, emailCC); 

    emailIntent.putExtra(android.content.Intent.EXTRA_BCC, emailBCC); 

    emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); 

    emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(emailBody)); 

    context.startActivity(Intent.createChooser(emailIntent, notification)); 

    return true; 

} 

回答

0

試試這個對我有用。

Intent emailIntent = new Intent(Intent.ACTION_SENDTO); 
emailIntent.setData(Uri.parse("mailto:")); 
emailIntent.putExtra(Intent.EXTRA_SUBJECT,BusinessName); 
emailIntent.putExtra(Intent.EXTRA_TEXT,Html.fromHtml(new StringBuilder().append(BusinessName+ "<br /><br />"+ LongDesc+ "<br /><br />"+ "<a href=\""+ ShareURL+ "\">"+ ShareURL+ "</a>").toString())); 
startActivity(Intent.createChooser(emailIntent, "Send email...")); 
+0

它不適用於我:(。問題是隻有與操作系統版本4.2.2 – Sujiz 2013-04-04 05:56:29

+0

你確定你更換了相同的代碼作爲我的? – Hasham 2013-04-04 06:02:29

+0

是啊你檢查這與4.2.2? – Sujiz 2013-04-04 06:06:59

1

差別不大,但也許有幫助。你可以試試這個其他意圖構造

Intent i = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + destination)); 

它爲我,這裏是我使用完整的方法:

public static void sendMail(Activity activity, String subject, String body, String destination) { 
    Intent i = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + destination)); 
    i.putExtra(Intent.EXTRA_SUBJECT, subject); 
    i.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body)); 
    activity.startActivity(Intent.createChooser(i, "Send mail...")); 
} 

希望工程。

相關問題