function CreateEmail(Recipient: string; Subject: string; Content: string;
Attachment: string; Attachment2: string = ''): boolean;
{$IFDEF ANDROID}
var
JRecipient: TJavaObjectArray<JString>;
Intent: JIntent;
Uri,Uri2: Jnet_Uri;
AttachmentFile: JFile;
AttachmentFile2: JFile;
{$ENDIF}
begin
{$IFDEF ANDROID}
JRecipient := TJavaObjectArray<JString>.Create(1);
JRecipient.Items[0] := StringToJString(Recipient);
Intent := TJIntent.Create;
Intent.setAction(TJIntent.JavaClass.ACTION_SEND);
Intent.setFlags(TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK);
Intent.putExtra(TJIntent.JavaClass.EXTRA_EMAIL, JRecipient);
Intent.putExtra(TJIntent.JavaClass.EXTRA_SUBJECT, StringToJString(Subject));
Intent.putExtra(TJIntent.JavaClass.EXTRA_TEXT, StringToJString(Content));
if Attachment <> '' then
begin
AttachmentFile := TJFile.JavaClass.init(StringToJString(Attachment));
Uri := TAndroidHelper.JFileToJURI(AttachmentFile);
Intent.putExtra(TJIntent.JavaClass.EXTRA_STREAM,
TJParcelable.Wrap((
Uri as ILocalObject).GetObjectID));
end;
if Attachment2 <> '' then
begin
AttachmentFile2 := TJFile.JavaClass.init(StringToJString(Attachment2));
Uri2 := TAndroidHelper.JFileToJURI(AttachmentFile2);
Intent.putExtra(TJIntent.JavaClass.EXTRA_STREAM,
TJParcelable.Wrap((Uri2 as ILocalObject).GetObjectID));
end;
Intent.setType(StringToJString('vnd.android.cursor.dir/email'));
Intent.setFlags(TJIntent.JavaClass.FLAG_GRANT_READ_URI_PERMISSION);
SharedActivity.startActivity(Intent);
result := true;
{$ENDIF}
{$IFDEF MSWINDOWS}
showmessage('Mail-Intent nur für Android !');
result := false;
{$ENDIF}
end;