You are here

Build email application with multiple image attachments

Hi...

I have developed a application which can send an email with one image
attachment.
Now i want to attach the multiple images.when i click a button email
should send to a hard coded email address with multiple image
attachments.
I used intents for my program. To send one image i used putExtra
method and send image as a EXTRA_STREAM.

Are their any way to implement this.If any body knows plz help me

my code for send one image is

public class emailFun extends Activity {

/** Called when the activity is first created. */

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.email_main);

Button btnSend = (Button) findViewById(R.id.mbutton);

btnSend.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {

if (v.getId() == R.id.mbutton) {
sendEmail();

}
}
});

}

public void sendEmail() {

String []mailto = {"mai...@domain.com"};

// Create a new Intent to send messages

Intent sendIntent = new Intent(Intent.ACTION_SEND);

sendIntent.putExtra(Intent.EXTRA_EMAIL, mailto);

Uri _uri=MediaStore.Images.Media.EXTERNAL_CONTENT_URI;

android.provider.MediaStore.Images.ImageColumns.DATA },null,
null,
null);

Cursor cursor = getContentResolver().query(_uri, new
String[]
{ android.provider.MediaStore.Images.ImageColumns.DATA },null, null,
null);

cursor.moveToFirst();

int i=cursor.getCount();

sendIntent.putExtra(Intent.EXTRA_SUBJECT,"Accsident
pictueres-
count"+i);

cursor.moveToFirst();

String imageFilePath1 = cursor.getString(0);

String modPath1="file://"+imageFilePath1;

Uri uPath1=Uri.parse(modPath1);

sendIntent.setType("image/jpg");

sendIntent.putExtra(Intent.EXTRA_STREAM,uPath1);

startActivity(Intent.createChooser(sendIntent,"send the
mail"));

cursor.close();
finish();

}

Forums: 

i have put this question on several forums and no solution has found so far. what i'm thinking at the moment is that whether this is possible.if you any solution for this plz share it with me. my new project needs o have this feature.