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 8712295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:04:52+00:00 2026-06-13T05:04:52+00:00

I am attaching an image from drawable folder and sending it in a email.

  • 0

I am attaching an image from drawable folder and sending it in a email.
when I send it from default email client.Image extension(.png) is missing in attachment
and and also the file name is changed itself.
I want t send image with default name(as in drawable) and with .png extension.

this is my code.

    Intent email = new Intent(Intent.ACTION_SEND);
            email.setType("image/png");

            email.putExtra(Intent.EXTRA_EMAIL, new String[] { to });

            email.putExtra(Intent.EXTRA_SUBJECT, "Hey! ");


            email.putExtra(Intent.EXTRA_STREAM, Uri.parse("android.resource://"+ getPackageName() + "/" + R.drawable.ic_launcher));
startActivity(Intent.createChooser(email, "Sending........"));

Please suggest me what is worng in this code
thanks.

  • 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-13T05:04:53+00:00Added an answer on June 13, 2026 at 5:04 am

    You can only attach an image to mail if the image is located in the SDCARD.
    So, you’ll need to copy the image to SD and then attach it.

    InputStream in = null;
    OutputStream out = null;
    try
    {
    in = getResources().openRawResource(R.raw.ic_launcher);
    out = new FileOutputStream(new File(Environment.getExternalStorageDirectory(), "image.png"));
    copyFile(in, out);
     in.close();
     in = null;
     out.flush();
    out.close();
    out = null;
    }
    catch (Exception e)
                    {
                        Log.e("tag", e.getMessage());
                        e.printStackTrace();
                    }
    
    private void copyFile(InputStream in, OutputStream out) throws IOException
        {
            byte[] buffer = new byte[1024];
            int read;
            while ((read = in.read(buffer)) != -1)
            {
                out.write(buffer, 0, read);
            }
        }
    
    
    Intent emailIntent = new Intent(Intent.ACTION_SEND);
                    emailIntent.setType("text/html");
                    emailIntent.putExtra(Intent.EXTRA_SUBJECT, "File attached");
                    Uri uri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "image.png"));
                    emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
                    startActivity(Intent.createChooser(emailIntent, "Send mail..."));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attaching image to explain my question in more detail. Also attaching android
Here I am attaching code in which store image in Drawable and pass to
I am attaching an asp.net textbox image I want my textbox should have two
Question What PHP library would you recommend for attaching meeting notices to email? Preference
I have 2 functions( js ) in a webpage for attaching an image to
I was trying recycle code for saving an image and attaching it to an
In the facebook graph api we have a attribute (picture) for attaching a image
I am having a bit of trouble attaching images from the Photo Gallery to
I need some help! :) I am trying to put a header png image
I am attaching an image. Some of you might have tried this iphone application

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.