简体   繁体   English

如何在Android中发送邮件?

[英]How will I send mail in Android?

I tried to send mail using with intent but it didn't work. 我尝试使用意图发送邮件,但是没有用。

    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);

try this: 尝试这个:

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 :"));  

尝试添加以下行:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM