sending email with attached pictures in android (solution)
the image is stored in android sd card
I got the solution we need to specify
<uses-permission android:name="android.permission.SEND_SMS"/>
in manifest and the working code is:
String _path = Environment.getExternalStorageDirectory() + "/mapp/test.jpeg";
File file = new File( _path );
Uri outputFileUri = Uri.fromFile( file );
if(file.exists())
{
//final ConnectivityManager connMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
//final int result = connMgr.startUsingNetworkFeature( ConnectivityManager.TYPE_MOBILE,Phone.FEATURE_ENABLE_MMS);
Toast.makeText(context,"exists",Toast.LENGTH_LONG).show();
Intent sendIntent = new Intent(Intent.ACTION开发者_Python百科_SEND);
sendIntent.setType("image/jpeg");
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {"abc@cde.com"});
sendIntent.putExtra(Intent.EXTRA_SUBJECT,"World Toyata(via Android App");
sendIntent.putExtra(Intent.EXTRA_STREAM,outputFileUri);
sendIntent.putExtra(Intent.EXTRA_TEXT,"Problem Area Image");
startActivity(Intent.createChooser(sendIntent, ""));
}
else
{
Toast.makeText(context,"SD CARD Required ",Toast.LENGTH_LONG).show();
}
}
Ramesh - I found value in your example but also found that it is was not necessary for me to have the permission android.permission.SEND_SMS.
I am wondering if it is necessary to have startActivity(Intent.createChooser(sendIntent, "Email:"));
where you specify "Email:".
精彩评论