2017-05-29 13 views
0

我試圖用意向發送郵件,但它沒有工作。我將如何在Android中發送郵件?

Intent intent = new Intent(Intent.ACTION_SEND); 
    intent.setType("message/rfc822"); 
    intent.putExtra(Intent.EXTRA_EMAIL, new String[]{adres}); 
    intent.putExtra(Intent.EXTRA_SUBJECT, konu); 
    intent.putExtra(Intent.EXTRA_TEXT, icerik); 
    startActivity(intent); 
+0

請解釋,**詳細**,什麼是 「它不工作」 的意思。 – CommonsWare

+0

沒有任何反應,我的郵箱上沒有新消息。 –

+0

不應該有[你的]郵箱上的「新郵件」。 'startActivity()'開始一個活動。那麼,什麼活動開始了? – CommonsWare

回答

0

試試這個:

Intent email = new Intent(Intent.ACTION_SEND); 
       email.putExtra(Intent.EXTRA_EMAIL, new String[]{ to}); 
       email.putExtra(Intent.EXTRA_SUBJECT, subject); 
       email.putExtra(Intent.EXTRA_TEXT, message); 

       //need this to prompts email client only 
       email.setType("message/rfc822"); 

       startActivity(Intent.createChooser(email, "Choose an Email client :")); 
0

嘗試添加下面一行:

startActivity(Intent.createChooser(intent, "Send email with: "));

相關問題