Jump to content

hehehmb

Members
  • Content Count

    1
  • Joined

  • Last visited

Community Reputation

0 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. hehehmb

    Send Email from Android with HTML message body

    Hi, I'm trying to send a email like that with a Attachment via Intent but the attachment is not attached. I created the fileprovider : <?xml version="1.0" encoding="utf-8"?> <paths xmlns:android="http://schemas.android.com/apk/res/android"> <external-path name="external_files" path="." /> </paths> and updated my manifest <provider android:name="androidx.core.content.FileProvider" android:authorities="%package%.provider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/fileprovider"/> </provider> <code> 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 if TJBuild_VERSION.JavaClass.SDK_INT >= TJBuild_VERSION_CODES.JavaClass.N then begin lFile := TJFile.JavaClass.init(StringToJString(Attachment)); Intent.setFlags(TJIntent.JavaClass.FLAG_GRANT_READ_URI_PERMISSION); Data := TJcontent_FileProvider.JavaClass.getUriForFile(TAndroidHelper.Context, StringToJString(JStringToString(TAndroidHelper.Context.getApplicationContext.getPackageName)+'.provider'), lFile); end else Data := TJnet_Uri.JavaClass.parse(StringToJString('file://' + Attachment)); Intent.setDataAndType(Data, StringToJString('message/rfc822')); SharedActivity.startActivity(Intent); end; </code> Thank you.
×