Root > How to... > ...send an e-mail?

...send an e-mail?

Previous pageReturn to chapter overviewNext page   

Option 1

Use EurekaLogSendEmail function from ESendMail unit. For example:


EurekaLogSendEmail('', 'Subject', 'Body');


or like this:


if not EurekaLogSendEmail('"John Smith" <>''Subject''Body''C:\Data\Attach1.txt;C:\Data\Attach2.png'then
  ShowMessage('Unable to send e-mail');


This function requires EurekaLog to be configured for your project.

It will send e-mail using already set up e-mail send method. Therefore, you have to set up at least one e-mail send method in your EurekaLog project options.



This function will use the first available e-mail send method;
If you did not set up any e-mail send method - a shell / mailto will be used;
Shell / mailto does not support file attaches, so be sure to set up any other e-mail send method if you want to send e-mails with attaches;
You can specify e-mail address like '' or '"Name" <>';
Attaches are optional, can be passed as semicolon-delimited string or as TStrings.



Option 2

If you do not want to use send settings from the project, e.g. you want to send e-mail using different account than set up for bug reports, or if you don't want to use / configure EurekaLog at all - then you may use overloaded version of EurekaLogSendEmail function from ESendMail unit to specify all the parameters manually. For example:


  ETypes,    // for TResponse
  ESendMail, // for EurekaLogSendEmail 
  ESendSMTP; // for TELMailSMTPClientSender
  R: TResponse;
  R := EurekaLogSendEmail(

    TELMailSMTPClientSender { which send method to use }

    '' { FROM field },
    '' { TO field }

    'Subject''Body'{ e-mail itself }
    '' { server }'' { login }'your-password' { password }, 587 { port }
    nil { file attaches in TStrings }
    nilnil{ for visual dialogs }
    ctTLS { plain, SSL or TLS });

  if Failed(Ord(R.SendResult)) then


This function does not require EurekaLog to be set up in your project. It do not use any EurekaLog project settings. You have to specify all necessary parameters manually.


Some IDE versions may be unable to resolve overload properly, producing either "ambiguous overload" or "there is no function with these arguments". If this is your case - try to use this:


  R: TResponse;
  PI: TELProgressIndicator; // added
  MP: TELProcessMessages; // added
  PI := nil// added
  MP := nil// added
  R := EurekaLogSendEmail(
    // ...
    PI, MP, { for visual dialogs } // changed
  // ...



SMTP client and GMail settings in the sample code above are just an example. You may use any other send method and any other e-mail server. For example, TELMailSimpleMAPISender class from ESendMailSMAPI unit for Simple MAPI, TELMailMAPISender class from ESendMailMAPI unit for MAPI, TELMailSMTPServerSender class from ESendMailSMTP for SMTP server, or TELMailShellSender class from ESendMailShell unit for shell / mailto;
Not all e-mail send methods require account details. For example: EurekaLogSendEmail(TELMailSimpleMAPISender, '' { not used }, '' { TO field }, 'Subject', 'Body' { e-mail itself });
If you want to use shell / mailto method - there is a simpler option (ESendMail unit): ShellSendMail('', 'Subject', 'Message');
Shell / mailto does not support file attaches;
You can specify e-mail address like '' or '"Name" <>';
You may add a visual feedback by using callback argument. See below for the example.



Option 3

EurekaLogSendEmail function is a wrapper around sender class. You may want to ignore it and just call class manually for finer control.


  // ...
  EDialogSendWinAPI, // [optional] For visual dialog during sending
  ETypes; // for TResponse
  TForm1 = class(TForm)
    // ...
    // [optional] For visual dialog during sending:
    FSendProgress: TSendDialogMSClassic;
// ...
  // ...
  EModules, // [optional] For CurrentEurekaLogOptions
  ESendMailSMTP; // for TELMailSMTPClientSender
procedure TForm1.Button1Click(Sender: TObject);
  MailSender: TELMailSMTPBaseSender;
  Rslt: TResponse;
  MailSender := TELMailSMTPClientSender.Create;
    // [optional] Copy EurekaLog project settings:
    MailSender.Options := CurrentEurekaLogOptions;
    // [optional] Set up send method 

    // Do this only if you did not copied CurrentEurekaLogOptions above
    MailSender.Options.SendSMTPClientHost := '';
    MailSender.Options.SendSMTPClientPort := 465;
    MailSender.Options.SendSMTPClientSSL := True;
    MailSender.Options.SendSMTPClientTLS := False;
    MailSender.Options.SendSMTPClientLogin := '';
    MailSender.Options.SendSMTPClientPassword := 'your-password';
    MailSender.Options.SendSMTPClientFrom := '';

    MailSender.Options.SendSMTPClientAdditionalHeaders := // [optional] 

            'BCC:'#13#10 +
            'X-Priority: 1'#13#10 +
            'X-MSMail-Priority: High'#13#10 +
            'Importance: High'#13#10;
    MailSender.Options.SendSMTPClientTarget := '';
    MailSender.Options.SendSMTPClientSubject := 'Header';
    MailSender.Options.SendSMTPClientMessage := 'Body';
    MailSender.Options.SendSMTPClientAppendLogs := False;
    MailSender.Options.SendSMTPClientUseRealEMail := False;
    // [optional] Attach a file on disk:
    // [optional] Attach a virtual file (TStream):
    MailSender.AttachedFiles.AddObject('Attach2.txt', Stream);
    // [optional] For visual dialog during sending:
    FSendProgress := TSendDialogMSClassic.Create(Handle, MailSender.Options);

      MailSender.ProgressIndicator := FSendProgress.ProgressIndicator;
      // Actual send
      Rslt := MailSender.SendMessage;

    // [optional] For visual dialog during sending:
    if Failed(Ord(Rslt.SendResult)) then



See also:

Send feedback... Build date: 2023-09-11
Last edited: 2023-03-07
The documentation team uses the feedback submitted to improve the EurekaLog documentation. We do not use your e-mail address for any other purpose. We will remove your e-mail address from our system after the issue you are reporting has been resolved. While we are working to resolve this issue, we may send you an e-mail message to request more information about your feedback. After the issues have been addressed, we may send you an email message to let you know that your feedback has been addressed.

Permanent link to this article: