android - 为 Android 发送带附件的 HTML 电子邮件

标签 android

我正在尝试使用 this solution但 Eclipse 仍然无法解析“附件”和“数据服务”。

我导入了 mail.jar 和 activation.jar,我做错了什么?我在 SO/Google 上尝试了无数其他发送电子邮件的解决方案,但我无法让它们中的任何一个处理我的附件并发送 HTML 电子邮件。

如有任何帮助,我们将不胜感激。

最佳答案

如果您需要构建由用户手动发送的电子邮件(用新电子邮件和附件打开他的邮件程序),您可以使用此代码:

Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setData(Uri.parse("mailto:" ));
emailIntent.setType("message/rfc822");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "SUBJECT");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "MESSAGE");
File toAttach = new File("/path/to/your/file");
Uri uri = Uri.fromFile(toAttach);
emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(emailIntent);

关于android - 为 Android 发送带附件的 HTML 电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9217164/

相关文章:

java - 如何获取 View 的父 fragment : 的实例

java - ArrayList 返回空值

android 媒体播放器播放时出错 : E/MediaPlayer(4768): error (1, -2147483648)

java - 尝试将字符串从 Web 写入文件时出现 FileNotFoundException(权限)

android - Android平台有类似iOS本地Notification的等效解决方案吗?

android - fragment 中 onCreateView 中的按钮始终为 null

java - RecyclerView onBindViewHolder indexOutOfBounds 尝试在 ArrayList 内绘制元素

android - 旋转后如何正确恢复 View 状态

android - 检查设备是否正在运行 Android-Things

android - 如何更改 EditText 指针颜色(不是光标)