0
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
        emailIntent.setType("image/jpg");
        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] 
        {"me@gmail.com"}); 
        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, 
        "Test Subject"); 
        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, 
        "go on read the emails"); 
        Log.v(getClass().getSimpleName(), "sPhotoUri=" + Uri.parse("file:///sdcard/2944154479.jpg"));
        emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/2944154479.jpg"));
        startActivity(Intent.createChooser(emailIntent, "Send mail..."));

我使用上面的代码将图像发送到电子邮件,电子邮件页面显示文件已附加但我只收到消息,附件没有收到我的邮件。

请帮助提前谢谢

4

3 回答 3

0

您首先必须将类型设置text/plain为添加您的消息。然后将类型设置jpeg/image为添加图像。否则您的信息将被误解。

   Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,getResources().getString(R.string.emlSendToFriendSubject));
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[]{emailto});
    emailIntent.setType("text/plain");
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,getResources().getString(R.string.emlSendToFriendBody));
    File file = getFileStreamPath(EMAIL_TEMP_FILE);
    emailIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    emailIntent.setType("image/jpeg");
    emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+file.getAbsolutePath()));
    startActivityForResult(Intent.createChooser(emailIntent, getResources().getString(R.string.btnSendToFriend)),ActMain.EMAIL_DONE);
于 2013-02-11T10:49:18.070 回答
0

请尝试以下代码,它将为您工作。

  Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
          emailIntent.setType("jpeg/image");
          emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                       new String[] { "" });
          emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "subject");
          Date cal = Calendar.getInstance().getTime();
          emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "body");

          Uri uri = Uri.fromFile(new File(Environment
                       .getExternalStorageDirectory(), "/HB.jpg"));

          emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
          emailIntent.setType("text/plain");

          startActivity(Intent.createChooser(emailIntent, "Send mail..."));
于 2013-02-11T10:48:10.807 回答
0

尝试这个 :)

String path = ...;

//Need to remove file:////, it has to be something like this storage/emulated/0/repertory/image.jpg
 if(path.startsWith("file")){
    path = path .replace("file:////", "");
 }

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(path)));
i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"test@test.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "Subject");
i.putExtra(Intent.EXTRA_TEXT   , "body");
startActivity(Intent.createChooser(i, "Sending email..."));
于 2013-11-15T16:36:24.927 回答