public RfQReportType getRfQReportType(final RfQResponsePublisherRequest request) {
   final I_C_RfQResponse rfqResponse = request.getC_RfQResponse();
   final PublishingType publishingType = request.getPublishingType();
   if (publishingType == PublishingType.Invitation) {
     if (rfqDAO.hasQtyRequiered(rfqResponse)) {
       return RfQReportType.Invitation;
     } else {
       return RfQReportType.InvitationWithoutQtyRequired;
     }
   } else if (publishingType == PublishingType.Close) {
     if (rfqDAO.hasSelectedWinnerLines(rfqResponse)) {
       return RfQReportType.Won;
     } else {
       return RfQReportType.Lost;
     }
   } else {
     throw new AdempiereException("@Invalid@ @PublishingType@: " + publishingType);
   }
 }
  public void publish0(
      final RfQResponsePublisherRequest request, final RfQReportType rfqReportType) {
    final I_C_RfQResponse rfqResponse = request.getC_RfQResponse();

    //
    // Check and get the user's mail where we will send the email to
    final I_AD_User userTo = rfqResponse.getAD_User();
    if (userTo == null) {
      throw new RfQPublishException(request, "@NotFound@ @AD_User_ID@");
    }
    final String userToEmail = userTo.getEMail();
    if (Check.isEmpty(userToEmail, true)) {
      throw new RfQPublishException(request, "@NotFound@ @AD_User_ID@ @Email@ - " + userTo);
    }

    //
    final IMailTextBuilder mailTextBuilder = createMailTextBuilder(rfqResponse, rfqReportType);

    //
    final String subject = mailTextBuilder.getMailHeader();
    final String message = mailTextBuilder.getFullMailText();
    final DefaultModelArchiver archiver =
        DefaultModelArchiver.of(rfqResponse)
            .setAD_PrintFormat_ID(getAD_PrintFormat_ID(rfqResponse, rfqReportType));
    final I_AD_Archive pdfArchive = archiver.archive();
    final byte[] pdfData = archiver.getPdfData();

    //
    // Send it
    final EMail email =
        mailBL.createEMail(
            rfqResponse.getAD_Client() //
            ,
            (String) null // mailCustomType
            ,
            (I_AD_User) null // from
            ,
            userToEmail // to
            ,
            subject,
            message,
            mailTextBuilder.isHtml() // html
            );
    email.addAttachment("RfQ_" + rfqResponse.getC_RfQResponse_ID() + ".pdf", pdfData);
    final EMailSentStatus emailSentStatus = email.send();

    //
    // Fire mail sent/not sent event (even if there were some errors)
    {
      final InternetAddress from = email.getFrom();
      final String fromStr = from == null ? null : from.toString();
      final InternetAddress to = email.getTo();
      final String toStr = to == null ? null : to.getAddress();
      archiveEventManager.fireEmailSent(
          pdfArchive // archive
          ,
          X_C_Doc_Outbound_Log_Line.ACTION_EMail // action
          ,
          (I_AD_User) null // user
          ,
          fromStr // from
          ,
          toStr // to
          ,
          (String) null // cc
          ,
          (String) null // bcc
          ,
          emailSentStatus.getSentMsg() // status
          );
    }

    //
    // Update RfQ response (if success)
    if (emailSentStatus.isSentOK()) {
      rfqResponse.setDateInvited(new Timestamp(System.currentTimeMillis()));
      InterfaceWrapperHelper.save(rfqResponse);
    } else {
      throw new RfQPublishException(request, emailSentStatus.getSentMsg());
    }
  }