【问题标题】:Android - Send email without user press SENDAndroid - 无需用户按 SEND 即可发送电子邮件
【发布时间】:2017-07-22 15:43:37
【问题描述】:

我有一个应用程序需要在没有用户交互的情况下发送电子邮件。 我已经开发了将默认电子邮件客户端设置为 GMAIL 的代码,但必须按 SEND。

Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
    emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    emailIntent.setType("plain/text");
    emailIntent.setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail");
    emailIntent.setData(Uri.parse("mailto:"));
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"user@mail.com"});
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "SUBJECT TEXT");
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "body text");
    startActivity(emailIntent);

之后,它将显示已填写字段的电子邮件表单,用户需要按“发送”按钮。 有人知道如何自动发送吗?

Gmail client waiting for user action to press SEND button

【问题讨论】:

标签: android email send interaction


【解决方案1】:

你可以通过 java mail api 做到这一点。

为此,您必须添加一些 jar 文件。

您必须点击此链接,因为它对我有用。

http://www.javatpoint.com/example-of-sending-email-using-java-mail-api

【讨论】:

猜你喜欢
  • 2019-11-27
  • 2018-05-03
  • 1970-01-01
  • 2022-08-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多