0

If I understand correctly, TSendMail is supposed to use my installed email client. If I execute it on my virtual machine, it returns "true" and gives me the expected message that I need to install an email program.

However, if I run the program on my regular machine (on which Thunderbird is installed) TSendMail.execute returns "True", but Thunderbird doesn't get called. Here's my code:

procedure TfSendEmail.btnSendClick(Sender: TObject);
var
  aNode: PVirtualNode;
  Data: PRecipients;
  i: integer;
begin
  aNode := vstRecipients.GetFirst;
  i := 0;
  while (aNode <> nil) do
  begin
    Data := vstRecipients.GetNodeData(aNode);
    Mail.Recipients.Add;
    Mail.Recipients[i].DisplayName := Data.Name;
    Mail.Recipients[i].Address := Data.Email;
    inc(i);
    aNode := vstRecipients.GetNext(aNode);
  end;

  Mail.Attachments.Assign(lbAttachments.Items);

  Mail.Subject := edtSubject.Text;

  Mail.Text.Assign(mmoMsgText.Lines);

  if Mail.Execute then
  begin
    ShowMessage('Succeeded');
    //ModalResult := mrOk;
  end
  else
    MessageDlg('Sorry!. Could not send email.', mtError, [mbOK], 0);
end;

Using Delphi 10.2.3 on fully updated Win10 machines. Maybe my recipient assignment is faulty. Anyway, I can't find any complete usage examples, only the incomplete example on attachments from Embarcadero's wiki.

Max Williams
  • 821
  • 1
  • 7
  • 13
  • 3
    `TSendMail` uses [MAPI](https://en.wikipedia.org/wiki/MAPI). See [here](http://kb.mozillazine.org/MAPI_Support) for Thunderbird MAPI support. I would avoid using that. You should use an SMTP-based emailing component. – Olivier Apr 27 '20 at 07:40
  • Thanks. I knew it was too simple.Should have read the documentation more carefully. – Max Williams Apr 28 '20 at 07:32

0 Answers0