public static Intent createEmailAttendeesIntent(Resources resources,String eventTitle,String body,List<String> toEmails,List<String> ccEmails,String ownerAccount){
  List<String> toList=toEmails;
  List<String> ccList=ccEmails;
  if (toEmails.size() <= 0) {
    if (ccEmails.size() <= 0) {
      throw new IllegalArgumentException("Both toEmails and ccEmails are empty.");
    }
    toList=ccEmails;
    ccList=null;
  }
  String subject=null;
  if (eventTitle != null) {
    subject=resources.getString(R.string.email_subject_prefix) + eventTitle;
  }
  Uri.Builder uriBuilder=new Uri.Builder();
  uriBuilder.scheme("mailto");
  if (toList.size() > 1) {
    for (int i=1; i < toList.size(); i++) {
      uriBuilder.appendQueryParameter("to",toList.get(i));
    }
  }
  if (subject != null) {
    uriBuilder.appendQueryParameter("subject",subject);
  }
  if (body != null) {
    uriBuilder.appendQueryParameter("body",body);
  }
  if (ccList != null && ccList.size() > 0) {
    for (    String email : ccList) {
      uriBuilder.appendQueryParameter("cc",email);
    }
  }
  String uri=uriBuilder.toString();
  if (uri.startsWith("mailto:")) {
    StringBuilder builder=new StringBuilder(uri);
    builder.insert(7,Uri.encode(toList.get(0)));
    uri=builder.toString();
  }
  Intent emailIntent=new Intent(android.content.Intent.ACTION_SENDTO,Uri.parse(uri));
  emailIntent.putExtra("fromAccountString",ownerAccount);
  if (body != null) {
    emailIntent.putExtra(Intent.EXTRA_TEXT,body);
  }
  return Intent.createChooser(emailIntent,resources.getString(R.string.email_picker_label));
}

public static Intent createEmailAttendeesIntent ( Resources resources , String eventTitle , String body , List < String > toEmails , List < String > ccEmails , String ownerAccount ) { List < String > toList = toEmails ; List < String > ccList = ccEmails ; if ( toEmails . size ( ) <= 0 ) { if ( ccEmails . size ( ) <= 0 ) { throw new IllegalArgumentException ( "Both toEmails and ccEmails are empty." ) ; } toList = ccEmails ; ccList = null ; } String subject = null ; if ( eventTitle != null ) { subject = resources . getString ( R . string . email_subject_prefix ) + eventTitle ; } Uri . Builder uriBuilder = new Uri . Builder ( ) ; uriBuilder . scheme ( "mailto" ) ; if ( toList . size ( ) > 1 ) { for ( int i = 1 ; i < toList . size ( ) ; i ++ ) { uriBuilder . appendQueryParameter ( "to" , toList . get ( i ) ) ; } } if ( subject != null ) { uriBuilder . appendQueryParameter ( "subject" , subject ) ; } if ( body != null ) { uriBuilder . appendQueryParameter ( "body" , body ) ; } if ( ccList != null && ccList . size ( ) > 0 ) { for ( String email : ccList ) { uriBuilder . appendQueryParameter ( "cc" , email ) ; } } String uri = uriBuilder . toString ( ) ; if ( uri . startsWith ( "mailto:" ) ) { StringBuilder builder = new StringBuilder ( uri ) ; builder . insert ( 7 , Uri . encode ( toList . get ( 0 ) ) ) ; uri = builder . toString ( ) ; } Intent emailIntent = new Intent ( android . content . Intent . ACTION_SENDTO , Uri . parse ( uri ) ) ; emailIntent . putExtra ( "fromAccountString" , ownerAccount ) ; if ( body != null ) { emailIntent . putExtra ( Intent . EXTRA_TEXT , body ) ; } return Intent . createChooser ( emailIntent , resources . getString ( R . string . email_picker_label ) ) ; }
create an intent for emailing attendees of an event .
