bzwirs 4 Posted January 7, 2021 Latest Delphi Trying to send email from Android that is always sent to one address but can have up to 3 CC addresses......the send to address shows up ok in the email but not any of the CC addresses. The code I use is shown below. Intent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_SEND); sRecipients := TJavaObjectArray<JString>.Create(1); sRecipients.Items[0] := StringToJString(Recipient); ccRecipient := TJavaObjectArray<JString>.Create(1); ccRecipient.Items[0] := StringToJString(ccTechs); Intent.putExtra(TJIntent.JavaClass.EXTRA_EMAIL,sRecipients); Intent.putExtra(TJIntent.JavaClass.EXTRA_CC, ccRecipient); Intent.putExtra(TJIntent.JavaClass.EXTRA_SUBJECT, StringToJString(aSubject)); Intent.putExtra(TJIntent.JavaClass.EXTRA_TEXT, StringToJString(aBody)); Intent.setType(StringToJString('plain/text')); TAndroidHelper.Activity.startActivity(TJIntent.JavaClass.createChooser(Intent, StrToJCharSequence('Which email app?'))); The ccTechs variable is a string of addresses - each address separated by a comma. All works fine except the ccRecipient is always missing. Can someone please explain what I am doing wrong. Thanks in advance Bill Zwirs Share this post Link to post
Lars Fosdal 1792 Posted January 7, 2021 What if you separate them with a semi-colon instead of a comma? Share this post Link to post
Remy Lebeau 1394 Posted January 7, 2021 (edited) 13 hours ago, bzwirs said: The ccTechs variable is a string of addresses - each address separated by a comma. EXTRA_CC takes a String[] array as input. You are creating a 1-element array holding a comma-delimited string. Try separating out the individual addresses instead, one address per array element. You could use Java's String.split() method for that, eg: Intent.putExtra(TJIntent.JavaClass.EXTRA_CC, StringToJString(Trim(ccTechs)).split(StringToJString('\s*,\s*')) ); Also, whether or not the email will populate the CC field is up to the email app that processes the Intent, it is not up to your code. It is possible that the email app you are testing with simply ignores the EXTRA_CC data. For example, Gmail 4.2 suffered from this problem, but that was fixed in Gmail 4.3. Edited January 7, 2021 by Remy Lebeau Share this post Link to post