Something wrong with the following code?
<p>i have made an application in android 2.2. In one of the activities i am supposed to send an attachment in an email. So for that i have written the following code:</p>

<pre><code>public void emailButtonClicked(View v) {
    Intent emailintent = new Intent(Intent.ACTION_SEND);
    try {
        HandleDatabase hb = new HandleDatabase();
        String data = hb.getAttachmentInfo(id);
        String details[] = data.split("--");
        String formatteddates[] = formatdate(details);
        details[2] = formatteddates[0];
        details[3] = formatteddates[1];
        InputStream myInput = this.getAssets().open("exportformat.txt");
        BufferedReader inputStream = new BufferedReader(
                new InputStreamReader(myInput));

        String outFileName = "/data/data/com.helios.NauticDates/attachment.ics";
        File checkfile = new File(outFileName);
        if (checkfile.exists()) {
            checkfile.delete();
        }
        for (int i = 0; i &lt; 4; i++) {
            if (details[i].equals("null"))
                details[i] = " ";
        }
        FileOutputStream myOutput = new FileOutputStream(outFileName);
        String datafromfile;
        while ((datafromfile = inputStream.readLine()) != null) {
            StringBuffer sb = new StringBuffer(datafromfile);
            if (datafromfile.equals("DTSTART:"))
                sb.append(details[2]);
            if (datafromfile.equals("DTEND:"))
                sb.append(details[3]);
            if (datafromfile.equals("SUMMARY:"))
                sb.append(details[0]);
            if (datafromfile.equals("DESCRIPTION:"))
                sb.append(details[1]);
            if (datafromfile.equals("CATEGORIES:"))
                sb.append(details[4]);
            datafromfile = sb.toString();
            datafromfile += "\n";
            byte[] temp = datafromfile.getBytes();
            myOutput.write(temp);
        }

        // Close the streams
        myOutput.flush();
        myOutput.close();
        inputStream.close();
        File tempfile = new File(outFileName);
        emailintent.putExtra(Intent.EXTRA_STREAM,
                Uri.fromFile(tempfile)); 
        emailintent.setType("plain/text");
        startActivity(Intent.createChooser(emailintent, "Send mail..."));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
</code></pre>

<p>In the above , the attachment is visible when the user starts the default email client, but when the user sends the email, the attachment is not received. the body, subject.. everything but the attachment is being received.
what is going wrong here.</p>

<p><strong>NOTE</strong></p>

<p>An ics file is a file for mac users which when clicked will directly add an event to the iCal app in the mac computer.</p>

<p><strong>Failed attempts</strong></p>

<p>i have already tried the following but they don't work:</p>

<ol>
<li><p>changed the MIME type to text/html</p></li>
<li><p>tried sending the extrastream like this:-i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + attachmentFilePath));?</p></li>
</ol>

<p>thank you in advance.</p>
