I am trying to send an email with an attachment, I have created a pdf file as well as a text file, for attaching a text file and sending an email i am using this code
email.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View arg0) {
                String path = "/ScriptEmails/"+ filename;
                String filepath = Environment.getExternalStorageDirectory()+File.separator+"Screenwriter"+File.separator+path;
                sendEmail ("text", "enter email here", "Script from scriptwrite android", "Your script is attached", filepath);
And the send email function is like this:
public void sendEmail (String attachmentType, String emails, String subject, String text, String filePath)
    {
        Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
        emailIntent.setType(attachmentType);
        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{emails}); 
        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,subject); 
        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, text); 
        emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///"+filePath/*mnt/sdcard/Myimage.jpeg"*/));
        startActivity(Intent.createChooser(emailIntent, "Send mail..."));
    }
now, the path is correct, the file name is correct, yet upon sending an email, it says, the attachment couldn't be send.
What i think is that i am not putting right ATTACHMENT TYPE for my file type.
What would be the attachment type for a text file and what would be an attachment type for a pdf file?
for text file i am using (txt/plain) is this correct?
 
     
    