Android编程-发送邮件
我在 Android 中使用以下代码来发送邮件:
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,sendTo );
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "test" );
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "msg" );
编译并运行代码时,它会询问我选择“GMail”、“蓝牙”等应用程序的选项。但我希望在没有用户的情况下发送邮件干涉。即使通过彩信发送对我来说也会好得多。有人可以建议我该怎么做吗?
I'm using the following piece of code in Android to send a mail:
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,sendTo );
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "test" );
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "msg" );
When code is compiled and run, its asking me options of selecting applications like "GMail", "BlueTooth" etc. But I want the mail to be sent without user intervention. Even sending it by MMS will be much better for me. Can some one suggest me how to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要在项目中包含 java 邮件库和依赖项,然后编写一个如下所示的帮助程序类。
JSSEProvider 类
发送电子邮件就像这样简单
You need to include the java mail library and dependencies in your project and then write a helper class like the one below.
the JSSEProvider class
Sending the email is then as simple as
如果没有用户干预,您无法使用内置应用程序发送电子邮件或短信。您必须像其他答案提到的那样使用外部邮件库。
You can't send an email or sms using the built-in apps without user intervention. You have to use an external mail library like the other answer mentions.