2012-03-25 13 views
0

send email画像添付で試しています。書き込み時に添付ファイルが表示されています、ボビーはすべてアフター受信メールで受信者にのみ表示されますsubject & Bodyのみアタッチメント私のコードは私のコードでは何がワゴンであるか分かりません。この仕事を終えるために私の提案をお願いします。アタッチメント(画像)付きメールをどう送信するのですか

タイプ1: -

Intent picMessageIntent = new Intent(Intent.ACTION_SEND); 
    picMessageIntent.setType("image/jpeg"); 
    File downloadedPic = new File(Environment.getExternalStorageDirectory(), strFileName + ".jpg");// Art_Nature 
    picMessageIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(downloadedPic));//screenshotUri);//Uri.fromFile(new File("downloadedPic"))); //Uri.fromFile(downloadedPic)); // Uri.fromFile(new File("/path/to/downloadedPic"))); 
     startActivity(Intent.createChooser(picMessageIntent, "Share image using")); 

タイプ2:

ArrayList<Uri> uris = new ArrayList<Uri>(); 
Uri u;   
Intent picMessageIntent = new Intent(Intent.ACTION_SEND); 
picMessageIntent.setType("image/jpeg"); 
File downloadedPic = new File(Environment.getExternalStorageDirectory(), strFileName + ".jpg");// Art_Nature   
if(downloadedPic.exists()) 
    { 
     Uri u1 = Uri.fromFile(downloadedPic); 
     uris.add(u1); 
     picMessageIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); 
     startActivity(picMessageIntent); 
    } 

答えて

4

ここではあなたを助けることができるものです。適切な方法でイメージファイルパスのスペルを確認してください。 "/"区切り記号(あなたのパスのログを取得しようとする)を忘れないでください。また、ファイルが存在することを確認してください。

/** ATTACHING IMAGE TO EMAIL AND SENDING EMAIL */ 
     Button b1 = (Button)findViewById(R.id.finalsectionsubmit); 
     b1.setOnClickListener(new View.OnClickListener() { 

     @Override 
     public void onClick(View v) { 

     Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
//  emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailSignature); 
     emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, toSenders); 
     emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subjectText); 
     emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, messageText+"\n\n"+emailSignature); 

     emailIntent.setType("image/jpeg"); 
     File bitmapFile = new File(Environment.getExternalStorageDirectory()+ 
      "/"+FOLDER_NAME+"/picture.jpg"); 
     myUri = Uri.fromFile(bitmapFile); 
     emailIntent.putExtra(Intent.EXTRA_STREAM, myUri); 


     startActivity(Intent.createChooser(emailIntent, "Send your email in:")); 
     eraseContent(); 
     sentMode = true; 
     } 
    }); 
+0

ここで、eraseContent()とsentmodeとは何か – Aerrow

+0

eraseContent()はプライベートメソッドで、sentModeはフラグです。メールを送信する必要はありません。上記のコードはAndroidプロジェクトのものです。 – Radu

+0

あなたの返信ありがとう – Aerrow

関連する問題