Trying to send an email with audio attachment.- unknown format
===

I am trying to send an email with my android devide over gmail. I am recording an audio first which produces the output in .3gp format. But now I want to attach this file to my mail. 
The following code does attach the file( i mean the proportionality of the duration of record is consistent with the size of the file, implying things are correct). But on receiving the file, the file has no format and is with the name "noname".

My recorded audio is here Environment.getExternalStorageDirectory().getAbsolutePath()+"/test.3gp"

I want to know what is the error and how to make it work
The code is 


    package com.mycomp.android.test;
    
    import java.io.ByteArrayOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    
    import android.annotation.SuppressLint;
    import android.app.Activity;
    import android.app.ProgressDialog;
    import android.graphics.Bitmap;
    import android.graphics.BitmapFactory;
    import android.media.MediaPlayer;
    import android.os.AsyncTask;
    import android.os.Bundle;
    import android.os.Environment;
    import android.os.StrictMode;
    import android.util.Log;
    import android.view.View;
    import android.widget.Button;
    import android.widget.Toast;
    
    @SuppressLint("ParserError")
    public class MailSenderActivity extends Activity {
    	
    	private static final String GMAIL_EMAIL_ID = "xyz@gmail.com";
    	private static final String GMAIL_ACCOUNT_PASSWORD = "xyz";
    	private static final String TO_ADDRESSES = "xyz@gmail.com";
    
    	/** Called when the activity is first created. */
    	@Override
    	public void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.main);
    
    		StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
    				.permitAll().build();
    		StrictMode.setThreadPolicy(policy);
    
    		writeFile();
    
    		final Button send = (Button) this.findViewById(R.id.send);
    		send.setOnClickListener(new View.OnClickListener() {
    
    			public void onClick(View v) {
    				MediaPlayer mPlayer = MediaPlayer.create(MailSenderActivity.this, R.raw.pleasewait);
            		mPlayer.start();
    				new MailSenderActivity.MailSender().execute();
    			}
    		});
    
    	}
    
    	private File imageFile;
    
    	private boolean writeFile() {
    		imageFile = new File(
    				getApplicationContext().getFilesDir() + "/images/",
    				"sample.png");
    
    		String savePath = imageFile.getAbsolutePath();
    		System.out.println("savePath :" + savePath + ":");
    
    		FileOutputStream fileOutputStream = null;
    		try {
    			fileOutputStream = new FileOutputStream(savePath, false);
    		} catch (FileNotFoundException ex) {
    			String parentName = new File(savePath).getParent();
    			if (parentName != null) {
    				File parentDir = new File(parentName);
    				if ((!(parentDir.exists())) && (parentDir.mkdirs()))
    					try {
    						fileOutputStream = new FileOutputStream(savePath, false);
    					} catch (FileNotFoundException e) {
    						e.printStackTrace();
    					}
    
    			}
    		}
    		byte[] bytes;
    		// here i am using a png from drawable resources as attachment. You can use your own image byteArray while sending mail. 
    		try{
    		FileInputStream neww= new FileInputStream(Environment.getExternalStorageDirectory().getAbsolutePath()+"/test.3gp");
    		
    		
    		ByteArrayOutputStream bos = new ByteArrayOutputStream();
    		byte[] b = new byte[1024];
    		int bytesRead;
    		while (( bytesRead =neww.read(b)) != -1) {
    		   bos.write(b, 0, bytesRead);
    		}
    		bytes = bos.toByteArray();
    		fileOutputStream.write(bytes);
    		fileOutputStream.close();
    		}
    		catch(Exception e){}
    		boolean result = true;
    
    
    		return result;
    
    	}
    
    	class MailSender extends AsyncTask<Void, Integer, Integer> {
    
    		ProgressDialog pd = null;
    
    		/*
    		 * (non-Javadoc)
    		 * 
    		 * @see android.os.AsyncTask#onPreExecute()
    		 */
    		@Override
    		protected void onPreExecute() {
    			// TODO Auto-generated method stub
    			super.onPreExecute();
    			pd = new ProgressDialog(MailSenderActivity.this);
    			pd.setTitle("Uploading...");
    			pd.setMessage("Uploading image. Please wait...");
    			pd.setCancelable(false);
    			pd.show();
    
    		}
    
    		/*
    		 * (non-Javadoc)
    		 * 
    		 * @see android.os.AsyncTask#doInBackground(Params[])
    		 */
    		@Override
    		protected Integer doInBackground(Void... params) {
    
    
    			Mail m = new Mail(GMAIL_EMAIL_ID, GMAIL_ACCOUNT_PASSWORD);
    
    			String toAddresses = TO_ADDRESSES;
    			m.setToAddresses(toAddresses);
    			m.setFromAddress(GMAIL_EMAIL_ID);
    			m.setMailSubject("Body");
    			m.setMailBody("Hello");
    
    //			try {
    //				ZipUtility.zipDirectory(new File("/mnt/sdcard/images"),
    //						new File("/mnt/sdcard/logs.zip"));
    //			} catch (IOException e1) {
    //				Log.e("MailApp", "Could not zip folder", e1);
    //			}
    
    			try {
    				String path = imageFile.getAbsolutePath();
    				System.out.println("sending path:" + path + ":");
    				m.addAttachment(path);
    
    				// m.addAttachment("/mnt/sdcard/logs.zip");
    
    				if (m.send()) {
    					
    					System.out.println("Message sent");
    					MediaPlayer mPlayer = MediaPlayer.create(MailSenderActivity.this, R.raw.success);
    	        		mPlayer.start();
    					return 1;
    				} else {
    					return 2;
    				}
    
    			} catch (Exception e) {
    				Log.e("MailApp", "Could not send email", e);
    			}
    			return 3;
    		}
    
    		/*
    		 * (non-Javadoc)
    		 * 
    		 * @see android.os.AsyncTask#onPostExecute(java.lang.Object)
    		 */
    		@Override
    		protected void onPostExecute(Integer result) {
    			// TODO Auto-generated method stub
    			super.onPostExecute(result);
    			pd.dismiss();
    
    			if (result == 1)
    				Toast.makeText(MailSenderActivity.this,
    						"Email was sent successfully.", Toast.LENGTH_LONG)
    						.show();
    			else if (result == 2)
    				Toast.makeText(MailSenderActivity.this, "Email was not sent.",
    						Toast.LENGTH_LONG).show();
    			else if (result == 3)
    				Toast.makeText(MailSenderActivity.this,
    						"There was a problem sending the email.",
    						Toast.LENGTH_LONG).show();
    
    		}
    	}
    
    }
