android - 在 Android 中通过电子邮件发送图像的可能方式有哪些?

标签 android email android-intent android-studio implicit

我正在使用以下代码发送 html 格式以在 Android 中发送电子邮件;现在我想用它发送图像。

   private void friends_email_share() {

    Log.i("Send email", "");
    String mail_body = "<!DOCTYPE html><html><body>\n" +
            "    <p>Hi,</p>\n" +
            "    <p>Lorem Ipsum <b>Lorem Ipsum Lorem Ipsum Lorem IpsumLorem </b> Lorem IpsumLorem  Ipsum</p>\n" +
            "    <p>Lorem IpsumLorem IpsumLorem IpsumLorem IpsumLorem IpsumLorem Ipsum.</p>\n" +
            "    <p>Lorem IpsumLorem  IpsumLorem IpsumLorem IpsumLorem IpsumLorem Ipsum.</p>\n" +
            "    <p>Lorem IpsumLorem  IpsumLorem IpsumLorem IpsumLorem IpsumLorem Ipsum.</p>\n" +
            "    <p>Lorem IpsumLorem IpsumLorem IpsumLorem  IpsumLorem IpsumLorem Ipsum.</p>\n" +
            "</body></html>";
    String[] TO = {};
    String[] CC = {};
    Intent emailIntent = new Intent(Intent.ACTION_SEND);
    emailIntent.setData(Uri.parse("mailto:"));
    emailIntent.setType("text/html");
    emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
    emailIntent.putExtra(Intent.EXTRA_CC, CC);
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Extra Subject");
    emailIntent.putExtra(Intent.EXTRA_TEXT, "" + "\n" + Html.fromHtml(mail_body));
    try {
        startActivity(Intent.createChooser(emailIntent, "Send mail..."));
        //getActivity().finish();
        Log.i("-->", "Finished sending email...");
    } catch (android.content.ActivityNotFoundException ex) {
        Toast.makeText(getApplicationContext(), "There is no email client installed.", Toast.LENGTH_SHORT).show();
    }

在android中通过电子邮件发送图片有哪些可能的方式?

我在这里需要认真的帮助,谢谢....

最佳答案

这可能对你有帮助..

尝试{

final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);  
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[] { "android@abcxyz.com" });
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Emergency");         
emailIntent.putExtra(Intent.EXTRA_STREAM,Uri.parse("file://"+ path + "/" + image_name));
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Please Find Attachments");
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
} catch (Throwable t) {
    Toast.makeText(MainActivity.this, "Request failed: " + t.toString(),Toast.LENGTH_LONG).show();
}

关于android - 在 Android 中通过电子邮件发送图像的可能方式有哪些?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30435051/

相关文章:

java - 将 boolean 值从注册发送到登录,但 toast 不工作

android - 如何返回 Activity 堆栈中某处的 Activity ?

android - 为什么在使用onclicklistener时我的应用程序崩溃了?

android - 如何使用 SugarORM 在数据库中创建另一个表

android - 如何布局按钮阵列以适应任何屏幕尺寸

Android - Facebook GraphUser 没有电子邮件属性

android - 无法返回主要 Activity

linux - 使用 Mutt 发送电子邮件而无需身份验证

javascript - 包含 JavaScript 的 Joomla 文章的电子邮件伪装替代方案