Bonjour,

Je suis en train de chercher une solution pour envoyer (de façon automatique) une photo choisie au préalable par l'utilisateur.

Pour ce qui est de l'ouverture de la galerie et de la sélection c'est OK, j'ai déjà la fonction d'envoi d'email qui n'attend plus qu'un paramètre -> Le chemin qui mène à la photo choisie..

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
procedure TForm1.BtCameraClick(Sender: TObject);
var
  ImageService: IFMXTakenImageService;
  Params: TParamsPhotoQuery;
begin
  PermissionsService.RequestPermissions([PermissionCamera, PermissionReadExternalStorage, PermissionWriteExternalStorage],TakePicturePermissionRequestResult, DisplayRationale)
End;
//------------------------------------------------------------------------------>
procedure TForm1.TakePicturePermissionRequestResult(Sender: TObject; const APermissions: TClassicStringDynArray; const AGrantResults: TClassicPermissionStatusDynArray);
var
  ImageService: IFMXTakenImageService;
  Params: TParamsPhotoQuery;
Begin
  Try
  if TPlatformServices.Current.SupportsPlatformService(IFMXTakenImageService,
    IInterface(ImageService)) then
  begin
    //Params.RequiredResolution := TSize.Create(640, 640);
    Params.OnDidFinishTaking := DoDidFinish;
    ImageService.TakeImageFromLibrary(BtCamera, Params);
  end;
  Except
    ShowMessage('Cannot take a photo because the required permissions are not all granted');
  End;
End;
//------------------------------------------------------------------------------>
procedure TForm1.DisplayRationale(Sender: TObject; const APermissions: TClassicStringDynArray; const APostRationaleProc: TProc);
begin
  var RationaleMsg: string;
 
  for var I := 0 to High(APermissions) do
  begin
    if APermissions[I] = PermissionCamera then
      RationaleMsg := RationaleMsg + 'The app needs to access the camera to take a photo' + SLineBreak + SLineBreak
    else if APermissions[I] = PermissionReadExternalStorage then
      RationaleMsg := RationaleMsg + 'The app needs to read a photo file from your device';
  end;
 
  // Show an explanation to the user *asynchronously* - don't block this thread waiting for the user's response!
  // After the user sees the explanation, invoke the post-rationale routine to request the permissions
  ShowMessage(RationaleMsg);
end;
//------------------------------------------------------------------------------>
procedure TForm1.DoDidFinish(Image: TBitmap);
Var Chemin : String;
begin
 
end;
 
procedure TForm1.DoMessageListener(const Sender: TObject; const M: TMessage);
begin
  if M is TMessageDidFinishTakingImageFromLibrary then
    Image1.Bitmap.Assign(TMessageDidFinishTakingImageFromLibrary(M).Value);
 
end;
Il y a un peu du sample fournit par Embarcadero, et un peu de la doc présente sur le site également, j'ai aussi trouvé TMessageReceivedImagePath dans la doc qui semble être ce que je recherche mais je n'arrive pas à m'en servir .

PS: Je tiens vraiment à envoyer l'image sans passer par la méthode de partage conventionnel qui laisse le choix à l'utilisateur, le but est d'automatiser une tache qui est effectuer à part après chaque formulaire rempli.