How to send email to multiple recepients in android?

后端 未结 3 1216
难免孤独
难免孤独 2020-12-10 23:27

I\'m a newbie in android. Please help me. I\'m not able to send email to multiple recipients. Here is my code.

public class SendEmailActivity extends Activit         


        
3条回答
  •  余生分开走
    2020-12-11 00:02

    First your conversion from List to String[] is wrong you need to do as follows..

    List list = new ArrayList();
    String[] arrayOfStrings = list.toArray(new String[list.size()]);
    

    And next thing is you need to mention android.Content.Intent as follows..

    So finally you need to change as follows

    ArrayList emailList;
    emailList = b.getStringArrayList("EmailList");
    String[] emailArray;
    
    Intent email = new Intent(android.content.Intent.ACTION_SEND);
    
    for(int i = 0; i < to.length; i++){
        Log.i("String is", (String)to[i]);
        email.putExtra(android.content.Intent.EXTRA_EMAIL, 
                       emailList.toArray(new String[emailList.size()]));
    }
    email.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
    email.putExtra(android.content.Intent.EXTRA_TEXT, message);    
    email.setType("message/rfc822"); //or email.setType("text/plain");
    
    startActivity(Intent.createChooser(email, "Choose an Email client :"));
    

提交回复
热议问题