Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7917275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:05:23+00:00 2026-06-03T15:05:23+00:00

My application uses the intent method to send out emails to users, as a

  • 0

My application uses the intent method to send out emails to users, as a convenient way of exporting Excel spreadsheet data (created by the JExcell API).

The file is contained on the SD card in a folder called records.

The file I am attempting to send is call measurments.xls.

I have tested in code for the existence of the file prior to sending. The email composer shows an attachment, but when I send and then receive the email the attachment is not there.

However, if I substitute the excel file for a png image, the attachment is received. So what gives??

Below is the code I use to send out the email, it is simply a paramiterised static method in a class by its self.

    public static  void sendEmailWithAttachment(Context ctx, String to,String subject, String message, String fileAndLocation)
    {
        Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
        emailIntent.setType("text/plain");
        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {to}); 

        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,  subject); 
        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,  message); 


          File file = new File(fileAndLocation);
         //  File file = getFileStreamPath();
           if (file.exists())
           {
               Log.v("Farmgraze", "Email file_exists!" );
           }
           else
           {
               Log.v("Farmgraze", "Email file does not exist!" );
           }


        Log.v("FarmGraze", "SEND EMAIL FileUri=" + Uri.parse("file:/"+ fileAndLocation));
        emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:/"+  fileAndLocation));

        ctx.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
    }//end method

So what do I need to do to receive the xls file? Change the mime types in the second line of the method’s code? If so what do. Any helpful advice would be greatly appreciated.

Thanks for reading.

A.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T15:05:25+00:00Added an answer on June 3, 2026 at 3:05 pm

    Ok folks just to add closure to this question I found the solution.

    The problem was that the file path String sent to the URI, needs to have three forward slashes.

    As in:

    file:///sdcard/somefolder/some_file.xls.
    

    Also for excel documents one needs to set the type as follows:

    emailIntent.setType("application/excel");
    

    So the problem was a two pronged one. I was aware of the three slash solution via this thread, but as it did not work thought the problem lie else where.

    Also I became aware of the correct mime types via this webpage which lists all of the supported mime types, and may be very useful for other readers.

    So thanks for reading and taking an interest in my little problem which is now solved.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our application uses SQL Server Reporting Services and allows users to add custom filters
My application uses a Spring DefaultMessageListenerContainer to process incoming messages. The main method of
For my application, I use the hover intent add-on for mouse over/out panels. This
My application uses MS access database to save some sensitive information. Though that information
Our application uses Hibernate with Sql Server 2005. Being a DBA, I am not
My application uses a large amount of Panda objects. Each Panda has a list
My application uses several threads with well-defined names (i.e. not a thread pool with
Our application uses a SQL Server back-end with many stored procedures. Recently, while trying
My application uses the UIImagePicker to allow the user to use the camera and
My application uses GPS updates while it is running and I would like that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.