programmatically send email with data file attachment

by Genesio » Wed, 10 Dec 2008 03:41:39 GMT

Sponsored Links
 Hello to everybody, i am writing a small program which creates a text
file on the external storage (microSD card).
Now i want to send this small file via email (asking the user which
account to use).

I read the sdk docs and I found that with an Intent and this action
Intent.html#ACTION_SENDTO) I can write an email.
But I cannot find any EXTRA_**** to specify an attachment.

I tried with EXTRA_STREAM and an open FileInputStream pointing to the
txt file, but when I see (for example) gmail popping out (basic email
writing works) there is no attachment in the "pre-built" email.

I know this is possible because I installed an application from the
market (Voice Recorder) that already does it.

I would want to reproduce its behaviour.

P.S. Another way to achieve my goal would be to upload via HTTP the
file to a webserver... maybe it's simpler? anyone can give me an
example or show me a JAVA library that implements this functionality??

Thank you


Other Threads

1. Download Android source code failed

I try to download source code for Android 2.0, but I always got the
"fatal: The remote end hung up unexpectedly" message.

Does the source code database with some problem? Should I rebuild my
repo environment? or change some setting of repo? please tell me how
to get the source code for Android 2.0.


2. Emulator Problem: No emulated GSM ubuntu 9.04 x64

Workaround Found!

Ok, admittedly this is a bit of a hack, but it DOES work and I've
tried it on a few different setups now.  When starting the emulator
add the following option: "-bootchart 100" (no quotes).  My current
theory is that there is a race condition on running the emulated gsm
stack and booting the emulator.  My machine is quite fast (quad core,
4GB ram), so I'm thinking the emulator is coming up before the gsm is
ready.  Adding the bootchart option might be slowing down the emulator
enough that the gsm comes up first.

To recap:
$ emulator -avd myavd -bootchart 100

Now your emulator will connect to the "Android" GSM network instead of
just giving you the "No Service" message.


3. what happened to my application's statistics?

4. I Didn't come here to cause no trouble, I just came to do the Android Market Shuffle!

5. Setting the ID in a SimpleAdapter

6. CameraSurfaceView and how surfaceCreated() gets called - Can someone please help me?

7. CameraSurfaceView and how surfaceCreated() gets called - Can someone please help me?