2013-05-11 24 views
3

當我嘗試發送電子郵件意向時,無論我使用INTENT.ACTION_SEND還是使用ACTION.SENDTO並使用股票Sony Xperia Active電子郵件客戶端,主題和收件人都顯示很好,但是除了客戶粘貼的標準評論外,其他人的身體都是空的。在我的三星Galaxy Note 2上,相同的代碼就像魅力一樣。使用意向時電子郵件正文不顯示

if(mPrefs.getBoolean("alternative_email_client", false)){ 
     Intent send = new Intent(Intent.ACTION_SENDTO); 
     String uriText = "mailto:" + Uri.encode(emailStrings[6]) + 
       "?subject=" + Uri.encode("The subject") + 
       "&body=" + Uri.encode(emailBody); 
     Uri uri = Uri.parse(uriText); 
     send.setData(uri); 
     startActivity(Intent.createChooser(send, "Email verschicken")); 
    } else { 
     Intent send = new Intent(Intent.ACTION_SEND); 
     send.putExtra(Intent.EXTRA_EMAIL, emailStrings[6]); 
     send.putExtra(Intent.EXTRA_SUBJECT, "The Subject"); 
     send.putExtra(Intent.EXTRA_TEXT, emailBody); 
     startActivity(Intent.createChooser(send, "Email verschicken")); 
    } 

回答

6

的類型要與身體,利用消息/ RFC822發送電子郵件。

Intent sendIntent = new Intent(Intent.ACTION_SEND); 
sendIntent.setType("message/rfc822"); 
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "[email protected]", "[email protected]" }); 
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject of the email"); 
sendIntent.putExtra(Intent.EXTRA_TEXT, "Content of the email"); 
startActivity(sendIntent); 

希望這會有所幫助。

+0

好吧,這有助於身體,但使用這個我得到一個新的問題:收件人不見了。如何解決這個問題? – neominik 2013-05-15 10:39:00

+0

奇怪。我嘗試過使用Gmail,我確實看到了收件人。你想從哪個應用發送電子郵件? – 2013-05-16 00:22:37

+0

這也適用於我:我忘記爲EXTRA_EMAIL使用字符串數組。它不適用於單個字符串。 – neominik 2013-05-21 10:40:08

0

嘗試添加消息

... 
emailIntent.setType("plain/text"); 
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, myMessage); 
... 
+0

嗯,我真的認爲我會有。但即使我添加了該行,該正文也不會顯示在股票電子郵件應用程序中。 – neominik 2013-05-15 10:37:23

相關問題