2017-01-05 11 views
0

画像をメールで送信します。今私はギャラリーから画像を選択していますが、エミュレータで表示されていますが、メールに同じ画像を送信する必要があります。ギャラリーから画像を選択していますが、同じ画像をアンドロイドでメールに送信したい

enter image description here

マイコード最後の引数は、画像ここ

new SendMailTask(Main2Activity.this).execute("[email protected]", 
       "unixxxxx", toEmails, "Testing", mbody, ???);//i don't know last argument how to send 

のためであるとして...私は値を渡した....

主な活動

public void onActivityResult(int requestCode, int resultCode, Intent data) { 
     if (resultCode == RESULT_OK) { 
      if (requestCode == SELECT_PICTURE) { 
       // Get the url from data 
       Uri selectedImageUri = data.getData(); 
       if (null != selectedImageUri) { 
        // Get the path from the Uri 
        String path = getPathFromURI(selectedImageUri); 
        Log.i(TAG, "Image Path : " + path); 
        // Set the image in ImageView 
        iv.setImageURI(selectedImageUri); 
       } 
      } 
     } 
    } 

です私は表示する必要があります...

0事前にの
public MimeMessage createEmailMessage() throws AddressException, 
      MessagingException, UnsupportedEncodingException { 

     mailSession = Session.getDefaultInstance(emailProperties, null); 
     emailMessage = new MimeMessage(mailSession); 

     emailMessage.setFrom(new InternetAddress(fromEmail, fromEmail)); 

      Log.i("GMail","toEmail: "+toEmailList); 
      emailMessage.addRecipient(Message.RecipientType.TO, 
        new InternetAddress(toEmailList)); 


     emailMessage.setSubject(emailSubject); 
     emailMessage.setContent(emailBody+,"text/html");// Here I have to display 
     // emailMessage.setText(emailBody);// for a text email 
     Log.i("GMail", "Email Message created."); 
     return emailMessage; 
    } 

おかげで...

答えて

1

はこれを試してみてください。それは私のために働いています。

Intent shareIntent = new Intent(Intent.ACTION_SEND_MULTIPLE); 
shareIntent.setType("text/plain"); 
shareIntent.setPackage("com.google.android.gm"); // This will open Gmail App on user's device 
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Email Subject"); 
shareIntent.putExtra(Intent.EXTRA_TEXT, "Extra text goes here"); 
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, fileUri); //fileUri is the Uri which is recieved in onActivityResult of Activity from Gallery Intent 
startActivityForResult(shareIntent, 12); 
+0

私は意図 –

+0

せずにメールを送信するSMTPを使って意図せずに電子メールを送信するには次のリンクを参照してください。http://stackoverflow.com/a/25136400/6800209 –

関連する問題