protected function sendEmail($body_text, $langcode, User $target) {
    // Translating frequency instance in the language of the user.
    // @codingStandardsIgnoreStart
    $frequency_translated = t($this->getName()->getUntranslatedString(), [], ['langcode' => $langcode]);
    // @codingStandardsIgnoreEnd

    // Construct the render array.
    $notification = [
      '#theme' => 'directmail',
      '#notification' => $body_text,
      '#notification_settings' => t('Based on your @settings, the notification above is sent to you <strong>:frequency</strong>', [
        '@settings' => Link::fromTextAndUrl(t('email notification settings', [], ['langcode' => $langcode]), Url::fromRoute('entity.user.edit_form', ['user' => $target->id()])->setAbsolute())->toString(),
        ':frequency' => $frequency_translated,
      ],
      ['langcode' => $langcode]),
    ];

    $params['body'] = \Drupal::service('renderer')->renderRoot($notification);

    // Send the email.
    $mail_manager = \Drupal::service('plugin.manager.mail');
    $mail_manager->mail(
      'activity_send_email',
      'activity_send_email',
      $target->getEmail(),
      $langcode,
      $params,
      NULL,
      TRUE
    );
  }