2

重複の可能性:
Androidで添付ファイル付きのメールを送信する方法は?

電子メールを送信すると、受信トレイに添付ファイル 0 バイトが表示されます。私のコードは以下です。この問題を解決するには?よろしくお願いします。

             String path = "/data/data/"
               + context.getApplicationContext().getPackageName()
               + "/files/";
             String filename= "save.ime";
             Intent mSendIntent = new Intent(
                android.content.Intent.ACTION_SEND);
        mSendIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mSendIntent.setType("plain/text");
        mSendIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                new String[] { "" });
        mSendIntent.putExtra(android.content.Intent.EXTRA_CC, "");
        mSendIntent.putExtra(android.content.Intent.EXTRA_BCC, "");
        mSendIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                "InfoMe Profile Request");
        mSendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new 
               File(path+filename)));
        mSendIntent.putExtra(android.content.Intent.EXTRA_TEXT,
                Function.bodypart);
        context.startActivity(Intent.createChooser(
                mSendIntent, "Send mail..."));
4

1 に答える 1

0

このコードを試してください:

filesend = new File("/data/data/"
           + context.getApplicationContext().getPackageName()
           + "/files/");
File filelocation = filesend ;
Intent mSendIntent = new Intent(Intent.ACTION_SEND);
mSendIntent.setType("image/jpeg");
mSendIntent.putExtra(Intent.EXTRA_EMAIL, "user@gmail.com" );
mSendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+filelocation.getAbsolutePath()));
startActivity(Intent.createChooser(mSendIntent, "Send email"));
于 2012-11-06T06:17:21.757 に答える