How to send email with Attachment(Image)

前端 未结 1 1932
北海茫月
北海茫月 2020-12-12 05:59

I am tryed two ways to send email with image attachment.The attachment is displaying at the time of writing subject,boby everything aftersend that email at the

相关标签:
1条回答
  • 2020-12-12 06:23

    Here is something that can help you. Make sure you spelled your image file path in a proper manner. Don't forget the "/" separator (try to get a log of your path). Also, be sure that the file exists.

    /** ATTACHING IMAGE TO EMAIL AND SENDING EMAIL  */
            Button b1 = (Button)findViewById(R.id.finalsectionsubmit);
            b1.setOnClickListener(new View.OnClickListener() {
    
          @Override
          public void onClick(View v) {
    
            Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
    //        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailSignature);
            emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, toSenders);
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subjectText);
            emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, messageText+"\n\n"+emailSignature); 
    
            emailIntent.setType("image/jpeg");
            File bitmapFile = new File(Environment.getExternalStorageDirectory()+
                "/"+FOLDER_NAME+"/picture.jpg");
            myUri = Uri.fromFile(bitmapFile);
            emailIntent.putExtra(Intent.EXTRA_STREAM, myUri);
    
    
            startActivity(Intent.createChooser(emailIntent, "Send your email in:"));
            eraseContent();
            sentMode = true;
          }
        });
    
    0 讨论(0)
提交回复
热议问题