You are not logged in.
Pages: 1

I tried this:
var
  body: variant;
  i: integer;
  files: array of RawUTF8;
  atm: array of variant;
  t: variant;
begin
  setLength(files, 2);
  files[0] := 'C:\temp\Faktura_se.pdf';
  files[1] := 'C:\temp\din.pdf';
  TDocVariant.new(body);
  if high(files) > -1 then
  begin
    SetLength(atm, high(files) + 1);
    for i := 0 to high(files) do
    begin
      TDocVariant.new(atm);
      t.name := extractFileName(files[i]);
      t.value := fileToBase64(files[i]);
      atm[i] := t;
    end;
    body.FileAttachments := _arr([atm]);
  end;but that just set FileAttachments to '{"FileAttachments":[null]}'
Is there a simple correction of this code?
Delphi-11, WIN10
Offline
TDocVariant.new(atm); doesn't mean anything.
I shouldn't compile.
I guess you meant  TDocVariant.new(atm[ i ]);
And no need to use an array of variant.
Just use a main TDocVariant array and TDocVariantData.AddItem() in the loop.
Offline

Thank you, that solved it!
Delphi-11, WIN10
Offline
Pages: 1