2011-05-13 120 views
0

我想從Android虛擬機發送電子郵件到我的Gmail帳戶。 問題:但按發送按鈕,我越來越「沒有應用程序可以執行此操作」。電子郵件活動

我在做什麼錯?

這裏是我的代碼:

 
Intent sendIntent = new Intent(Intent.ACTION_SEND); 
sendIntent.setType("audio/mp3"); 
//sendIntent.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/mysong.mp3"); 
//sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/download/test.mp3")); 
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(GlobalVariable.getstrEmail())); 
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject"); 
startActivity(Intent.createChooser(sendIntent, "Title:")); 

回答

2

嘗試一個真正的設備本身,它應該工作。並且您需要更改類型:

final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
emailIntent.setType("plain/text"); 
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"[email protected]"}); 
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "subject"); 
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "body text"); 
startActivity(Intent.createChooser(emailIntent, "Send mail...")); 
+0

我設置了mp3,因爲我必須發送帶附件的mp3文件 – Android 2011-05-14 06:57:13

0

試試這個....

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);   
      emailIntent.setType("plain/text"); 
      emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{emailaddress});           
      startActivity(Intent.createChooser(emailIntent, "Send mail...")); 
1

這可以幫助...

Intent openEmailIntent = new Intent(android.content.Intent.ACTION_SEND); 
    openEmailIntent.setType("plain/text"); 
    openEmailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, 
          new String[{"[email protected]"}); 
    openEmailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"subject you want"); 
    openEmailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Any body "); 
    this.startActivity(Intent.createChooser(openEmailIntent,"Sharing via Email"));