Reputation: 8129
I need to include an image in the email which is send from my app. I have written the code to include text and it is working fine.but I don't know how to include image.my image resides in the drawable folder.how can I include that? NB:I have gone through many posts but nothing helped me..
edit:
my current code is given below
emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body,new ImageGetter() {
@Override
public Drawable getDrawable(String source) {
Drawable drawFromPath;
// int path = getActivity().getResources().getIdentifier(source, "drawable", "com.package...");
drawFromPath = (Drawable) getActivity().getResources().getDrawable(R.drawable.ic_launcher);
drawFromPath.setBounds(0, 0, drawFromPath.getIntrinsicWidth(),
drawFromPath.getIntrinsicHeight());
return drawFromPath;
}
}, null));
emailIntent.setType("text/html");
Upvotes: 0
Views: 238
Reputation: 68167
You can attach an image by setting the following two values:
Uri uri = Uri.fromFile(new File("directory's path", "filename"));
intent.setType("image/jpeg");
intent.putExtra(Intent.EXTRA_STREAM, uri);
Upvotes: 1