problem sending an email with an attachment programmatically

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

problem sending an email with an attachment programmatically

Postby mudit.agar » Sat Aug 08, 2009 5:20 am

hello..

i`m trying to send an email using native email client on android
phone.

I have tried following ways to add an attachment to the mail...

method--1
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("image/jpeg");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://sdcard/
abc.jpg"));

method 2

Sending the image as body content---

sendIntent.putExtra(Intent.EXTRA_TEXT, "<HTML><BODY><b><IMG SRC=
\"data:image/jpeg;base64," + <imagepath> + "\"alt = \"pleaseview this
image\"/></b></BODY></HTML>");

i can successfully attach the image manually but when i tried to
attach and send it programmatically the mail was sent without
attachement.

Please let me know if there is a way to send an attachment
programmatically by using email client
mudit.agar
Freshman
Freshman
 
Posts: 9
Joined: Tue Jun 16, 2009 11:41 am

Top

Postby stifry » Fri Aug 14, 2009 12:02 am

You have the right idea with Method 1. This is how I do it:

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
sendIntent.putExtra(Intent.EXTRA_TEXT, context.getResources().getString(R.string.session_send_file_body_text_image));
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+Environment.getExternalStorageDirectory()+"/trackmaster_session.png"));
sendIntent.setType("image/png");

Just make sure the image is actually there.
Visit Trackaroo.com!
Trackmaster - Motorsports Lap Timer
Dynomaster - Performance Dyno
Image Image
User avatar
stifry
Developer
Developer
 
Posts: 46
Joined: Tue Feb 17, 2009 7:50 pm

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 4 guests