如何在Android中发送带有附件的电子邮件

By reading this piece, you will learn to send an email directly from the application in an Android application. We will be using the JavaMail API which helps to facilitate the authentication to the SMTP server.

通过阅读本文,您将学习直接从Android应用程序中的应用程序发送电子邮件。 我们将使用JavaMail API ,它有助于简化对SMTP服务器的身份验证。

JavaMail API:

JavaMail API:

“… provides a platform-independent and protocol-independent framework to build mail and messaging applications. The JavaMail API is available as an optional package for use with the Java SE platform and is also included in the Java EE platform.”

“……提供了独立于平台和协议的框架来构建邮件和消息传递应用程序。” JavaMail API作为与Java SE平台一起使用的可选软件包提供,也包含在Java EE平台中。”

There are three sections in this article:

本文分为三个部分:

  1. Setup

    建立
  2. Implementation

    实作
  3. Conclusion

    结论

1.设定 (1. Setup)

Make sure that you have installed Android Studio and downloaded the necessary SDK and build tools.

确保已安装Android Studio并下载了必要的SDK和构建工具。

Create a new project with an Empty Activity. Head over to the following download link and download all of the files. You should have the following files.

Empty Activity创建一个新项目。 转到下面的下载链接并下载所有文件。 您应该具有以下文件。

Please be noted that these dependencies are not the latest version. If you prefer to get the latest version, head over to the following JavaMail link and download the respective javax.mail.jar for 1.6.2.

请注意,这些依赖项不是最新版本。 如果您希望获得最新版本,请转到下面的JavaMail链接并下载用于1.6.2的相应javax.mail.jar

Place all of the jar files inside the libs folder of your project.

将所有jar文件放在项目的libs文件夹中。

Image for post

Right-click on them and “Add as Library”. Check the gradle.build (Module: app) file. You should have the following code inside the dependencies.

右键单击它们,然后单击“添加为库”。 检查gradle.build (Module: app)文件。 您应该在依赖项中包含以下代码。

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值