2014-02-12 7 views
0

在身體形象的Android電子郵件我有一個應用程序中,我需要用文字和IMG身體發送電子郵件.... img的是從SD卡正在添加這樣從存儲

enter image description here 我做到了這一點......

emailIntent.setData(Uri.parse("mailto:")); 
      emailIntent.setType("text/plain"); 
      emailIntent.setType("application/image"); 

      emailIntent.putExtra(Intent.EXTRA_EMAIL, TO); 
      emailIntent.putExtra(Intent.EXTRA_CC, CC); 
      emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Your subject"); 
      emailIntent.putExtra(Intent.EXTRA_TEXT, "Email message goes here"); 
      Spanned spanned_str_Caution = Html.fromHtml(str_Caution); 
      String text=tv_viewinfo.getText()+""+spanned_str_Caution; 
      emailIntent.putExtra(Intent.EXTRA_TEXT, text); 




      // emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/saved_images/test.PNG")); 
      // emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///mnt/sdcard/saved_images/test.PNG")); 
      // root 
       //emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///mnt/sdcard/saved_images/test.PNG")); 
      // emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///mnt/sdcard/saved_images/test.PNG")); 
      startActivity(Intent.createChooser(emailIntent, "Send mail...")); 
      finish(); 
      Log.i("Finished sending email...", ""); 

但是這不是爲我工作和應用程序崩潰..

+1

什麼是logcat中的錯誤。發表它 –

回答

0

你可以嘗試這樣的,

Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); 
     // intent.setType("text/plain"); 

     intent.setType("message/rfc822"); 
     // intent.setType("image/*"); 
     intent.putExtra(Intent.EXTRA_SUBJECT, "Img Send"); 
     intent.putExtra(Intent.EXTRA_TEXT, "test"); 
     ArrayList<Uri> uris = new ArrayList<Uri>(); 

     for (int k = 0; k < fmsgList.size(); k++) { 
      File fileIn = new File(fmsgList.get(k)); 
      Uri u = Uri.fromFile(fileIn); 
      uris.add(u); 
     } 
     File root = Environment.getExternalStorageDirectory(); 

     File file1 = new File(root, "/File.txt"); 
     Uri u = Uri.fromFile(file1); 
     uris.add(u); 

     intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); 
     // startActivity(intent); 
     startActivity(Intent.createChooser(intent, "Send E-mail...")); 
0

這樣的發送路徑

String file_path = Environment.getExternalStorageDirectory() + "/saved_images/test.PNG" 
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(file_path);