2012-12-20 209 views
0

我目前正在開發一個android項目,並且添加了一個首選項以便能夠向我發送電子郵件。我正在使用ACTION_SENDTO意圖發送電子郵件,但它的回來,並說No apps can perform this action通過意向發送電子郵件

下面是我使用

Intent intent = new Intent(Intent.ACTION_SENDTO); 
       intent.setType("text/plain"); 
       intent.putExtra(Intent.EXTRA_EMAIL, "[email protected]"); 
       intent.putExtra(Intent.EXTRA_SUBJECT, "Check out this android app"); 
       intent.putExtra(Intent.EXTRA_TEXT, "Check out this new app in the Google Play Store. Its from Boardies IT Solutions and is called Boardies Password Manager. You can find it at https://play.google.com/store/apps/details?id=com.BoardiesITSolutions.PasswordManager"); 
       startActivity(Intent.createChooser(intent, "Send Email")); 

感謝代碼任何幫助,您可以提供

+0

你是在模擬器或真實設備嘗試? –

+0

它在一個真實的設備上。還安裝了gmail – Boardy

+0

您在發送電子郵件之前是否登錄? –

回答

1

您需要添加以下

intent.setData(Uri.parse(」 mailto:「+」[email protected]「)); //離開 空白如果沒有特異性

+0

我以爲使用ACTION_SEND顯示的應用程序不是電子郵件客戶端如Facebook和Twitter等,這就是爲什麼我選擇ACTION_SENDTO,因爲我認爲這隻會顯示電子郵件客戶端。 – Boardy

+0

啊對了,不知道你想要電子郵件獨家,看着它... – Jug6ernaut

+0

答覆修訂,這爲我提出了gmail應用程序。 – Jug6ernaut

0

我想你應該更換Intent.ACTION_SENDTOIntent.ACTION_SEND
希望這會爲你工作。

這個怎麼樣代碼:

final Intent emailLauncher = new Intent(Intent.ACTION_SEND); 
emailLauncher.setType("message/rfc822"); 
emailLauncher.putExtra(Intent.EXTRA_EMAIL, "[email protected]"); 
emailLauncher.putExtra(Intent.EXTRA_SUBJECT, "check this subject line"); 
emailLauncher.putExtra(Intent.EXTRA_TEXT, "hey check this message body!"); 
try{ 
     startActivity(emailLauncher); 
}catch(ActivityNotFoundException e){ 

}