当前位置: 首页 > 面试题库 >

在Android中使用GMail发送电子邮件

祁坚壁
2023-03-14
问题内容

我试图直接在单击按钮时打开Gmail的电子邮件发送表单,但这总是显示用于发送电子邮件的选项列表。

我这样做是为了打开GMail表单:

            Intent emailIntent = new Intent( android.content.Intent.ACTION_SEND);
            String[] recipients = new String[]{"" , "" ,};
            emailIntent.putExtra( android.content.Intent.EXTRA_EMAIL, recipients);
            emailIntent.putExtra( android.content.Intent.EXTRA_SUBJECT, "This is my text" );
            emailIntent.putExtra( android.content.Intent.EXTRA_TEXT, "");
            emailIntent.setType("message/rfc822");
            startActivity( Intent.createChooser(emailIntent, "Send Email" ));

但这不是打开GMail表单。我应该怎么做才能打开GMail表单,请帮忙。

有什么办法吗?


问题答案:

在线路上使用一些东西

public void sendGmail(Activity activity, String subject, String text) {
    Intent gmailIntent = new Intent();
    gmailIntent.setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail");
    gmailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
    gmailIntent.putExtra(android.content.Intent.EXTRA_TEXT, text);
    try {
      activity.startActivity(gmailIntent);
    } catch(ActivityNotFoundException ex) {
      // handle error
    }
}


 类似资料:
  • 需要使用spring boot从gmail发送邮件 但我得到了一个错误,就像 此应用程序没有/error的显式映射,因此您将其视为回退。 出现意外错误(type=内部服务器错误,状态=500)。邮件服务器连接失败;嵌套异常是com.sun.mail.util.MailConnectExc0019:无法连接到主机,端口:smtp.gmail.com,587;超时5000;嵌套异常是:java.net

  • 我正在尝试使用gmail从Delphi发送电子邮件。我有Indy10.5.9.0和Delphi XE3。 我从中获得了示例代码:http://www.andrecelestino.com/delphi-xe-envio-de-e-mail-com-componentes-indy/ 我还尝试了其他示例代码,但结果相同。 我有libeay32.dll和ssleay32.dll从这里:http://w

  • 我正在使用C#使用SMTP和gmail服务器发送电子邮件。 下面是我用于发送电子邮件的代码。我遇到了一些错误,即。 SMTP服务器需要安全连接,或者客户端未通过身份验证。服务器响应为:需要5.5.1身份验证。 我做错了什么?我如何使用gmail发送电子邮件。

  • 我用竹子来让我的网站访问者填写并发送一份联系表。 我创建了一个服务帐户 我授予它全域权限 我添加了以下范围:https://www.googleapis.com/auth/gmail.addons.current.action.compose https://www.googleapis.com/auth/gmail.addons.current.message.metadatahttps://w

  • 我在ASP. Net Core中工作,并尝试从gmail使用smtp客户端发送电子邮件。有以下代码,但不起作用也看过以下帖子,但不起作用http://dotnetthoughts.net/how-to-send-emails-from-aspnet-core/ 它会跟踪错误 系统NotSupportedException:SMTP服务器不支持身份验证

  • 我在我的网站上创建了一个联系表单,并且,为了向网站帐户发送电子邮件(contact@mywebsite.com),我正在使用gmail smtp,使用与接收邮件相同的电子邮件。 所以,用户进入我的网站,点击联系页面,填写表格:姓名,电子邮件,信息。 比我发送以下代码的电子邮件: 电子邮件将进入“我的收件箱”contact@mywwebsite.com“,我可以正常阅读邮件,但是。。。当我点击“回复