2012-03-27 3 views
0

PHPサーバーから画像を取得して文字列(this image)として送信します。この画像を添付ファイルとして電子メールで送信します。文字列をファイルに変換して電子メールの添付ファイルとして送信

電子メールを送信しようとすると、添付ファイルは紙になりますが、受信者側にプレーンテキストのみが表示されます。電子メールを正しく送信するにはどうすればよいですか?

これは私のコードです:

Intent picMessageIntent = new Intent(android.content.Intent.ACTION_SEND); 
picMessageIntent.setType("image/jpeg"); 
String img_source = listBuzzInfoBean.get(photo).getBuzzImage(); 
File downloadedPic = new File(Environment.getExternalStorageDirectory(), img_source + ".jpg");// Art_Nature 

Log.d("++++++++++++++", img_source); 
Uri myUri = Uri.fromFile(downloadedPic); 
picMessageIntent.putExtra(Intent.EXTRA_STREAM, myUri); //screenshotUri 
startActivity(Intent.createChooser(picMessageIntent, "Share image using")); 

答えて

0

私はこれを処理するために、次のコードを使用していました。私は、Gmail/Mailアプリとその意図をどのように扱うかの違いに気付きました。

また、この投稿にも同様の問題があるようです。 Android: Intent.ACTION_SEND with EXTRA_STREAM doesn't attach any image when choosing Gmail app on htc Hero

public static Intent createEmailWithAttachmentIntent(String[] addresses, 
     String[] ccAddresses, String subject, String contentType, 
     String filename, String messageBody) { 
    Intent i = new Intent(Intent.ACTION_SEND); 
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
    i.putExtra(Intent.EXTRA_EMAIL, addresses); 
    i.setType(contentType); 
    if(filename != null && !filename.equals("")) 
     i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(filename))); 
    i.putExtra(Intent.EXTRA_SUBJECT, subject); 
    i.putExtra(Intent.EXTRA_TEXT, messageBody); 

    if (ccAddresses != null && ccAddresses.length > 0) 
     i.putExtra(Intent.EXTRA_CC, ccAddresses); 
    return i; 
} 
関連する問題