how to attach image and location to email in android sdk? - android

hi iam developing an android app in it we can take photo and send it to default email i implement capturing of image with MeadiaStore.ACTION_IMAGE_CAPTURE);
and i get location by using location.getLatitude() , location.getLongitude();
then how to attach this image and location to email like subject as email.putExtra(Intent.EXTRA_SUBJECT,"subject");

First you have to store the captured image in sdcard and the Use this code to send email
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("application/image");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{strEmail});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Test Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "From App");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///mnt/sdcard/Myimage.jpeg"));
startActivity(Intent.createChooser(emailIntent, "Send mail..."));

Related

How to send an image as email attachment from application?

I'm currently trying to create an app that will take a picture and then attach that picture to an email and send the email.
what i m trying to say
step
1. add recipient Email Address.
2. add Subject.
3. add Some Text.
and Last And Main
4. Attach image from camera and sent that Mail.
I want to send mail from my own application only?? without using any inbuilt Gmail app?
Try below code
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("application/image");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{strEmail});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Test Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "From My App");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///mnt/sdcard/Myimage.jpeg"));
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
UPDATE
Try this link, it will help you

How to let user select images to attach using email intent in android?

So, i was working on this idea where i can let user select an image from a folder when they click on a button and that particular image/images can be send as an attachment using email intent in android. I have been successful in sending one picture or many pictures but the fact is i have to declare those images in my code. I want something like OpenFileDialog which can allow me to choose an image at runtime. Is there a way to do that?
case R.id.button2:
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/plain");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getResources().getString(R.string.reccomendation_subject));
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, getResources().getString(R.string.recomendation_body));
emailIntent.setType("image/png");
File bitmapFile = new File(Environment.getExternalStorageDirectory()+"/test_1.png");
Uri myUri = Uri.fromFile(bitmapFile);
emailIntent.putExtra(Intent.EXTRA_STREAM, myUri);
startActivity(Intent.createChooser(emailIntent, "Send your email in:"));
break;

email share intent android - html styles are not working

I tried following code
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
shareEmailSubject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
Html.fromHtml("<b>text to be shared</b><br>link");
but when I send the email, no styles are appearing while
1. sending the email
2. After email is received on desktop email client(eg. gmail)
i tried your code and it is working fine at my end
String body = "<b>text to be shared</b><br>link";
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "hi");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
Html.fromHtml(body));
startActivity(Intent.createChooser(emailIntent, "Email:"));
The problem which I was facing was due to default android mail client, when I switched to share via gmail, it worked perfectly fine.

Email intent always launch gmail by default

String body="message";
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Check out this book I am reading");
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body);
startActivity(Intent.createChooser(emailIntent, "Send email..."));
No matter what I do (removing all gmail accounts and signin a hotmail account with mail app), this code launches Gmail by default and do not show or let me choose my universal mail app.
Consequently, there is no way to let user send email via hotmail or other mail provider.
update:
Actually this is the best piece of code I ever come across, it presents you directly with an app chooser where only mail client are present. The answer below will give you a huge list of apps to choose from that are irrelevant.
String mailTo="";
Intent email_intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto",mailTo, null));
email_intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject text here");
email_intent.putExtra(android.content.Intent.EXTRA_TEXT,"Body text here");
startActivity(Intent.createChooser(email_intent, "Send email..."));
Try using the correct MIME type (text/plain) instead of an invalid MIME type (plain/text).

how to send image in email body via Android application

i have to sent image via my application in mail body.
but i am unable to see that image in mail editor. it only shows rectangular box with written "OBJ" inside.
thanx.
I am using the following code.
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"Product:"+ProductComparisonActivity.s_title);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Title:
"+ProductComparisonActivity.s_title+"\n"+"Description:
"+ProductComparisonActivity.s_des+"\n"+"\n"+"Max Price:
"+ProductComparisonActivity.s_max+"\n"+"Min Price:
"+ProductComparisonActivity.s_min+"\n");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml("<img src="+"\""+ProductComparisonActivity.image_med+";base64,#IMAGEDATA#"+"\">",imgGetter,null));
// emailIntent.putExtra(Intent.EXTRA_STREAM, ProductComparisonActivity.prod_bmp);
emailIntent.setType("text/html");
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
Sorry, I don't think it is possible.

Categories

Resources