eMails with a file-attachement are not in the eMail-Log

Hi,

I am using the latest cuba-platform-6.8.4 and have a little problem
with sending eMails. Everything is working fine with sending, when I am not using
an attachement. The email is send an I find it after sending in the eMail-send-log.
But when I attach a pdf-File the eMail is send, but it is not in the log.
Is there a setting for the logging-structure, that I did not found ?

I cannot find anything wrong, even the mail is going out ?

Thanks

Hi,
Unfortunately, we are unable to reproduce the problem. Could you please provide more details?

  1. Which “log” do you mean: server log (Administration->Server Log) or email history (Administration->Email history)?
  2. How many attachments has the email?
  3. Which size has the PDF document? could you share it?
  4. How do you send the email? Could you share the code or prepare a sample project?

Hi,

thank you for your reply.
The log I mean is the eMail-log.

There is only one small attachment, see this example: angebot_1001_kdnr_197.pdf (258.0 KB)

Here is a code-snip:

private boolean sendeBelegPerEmailIfSettings(ENUM_BELEGTYP belegTyp, File anlage, String fileName, boolean realPrint) {
boolean bRet = false;

    if (!realPrint) {
        return false;    //testdrucke werden nicht vermailt
    }


    if (this.cbUseEmail.isChecked() && S.isFull(this.tfEmail.getValue())) {
        String eMailTarget = this.tfEmail.getValue();
        String betreff = "Automatikversand: "+fileName;

        SimpleDateFormat format = new SimpleDateFormat();
        format.applyPattern("yyyy-MM-dd HH:mm:ss");
        betreff=betreff+" ... "+format.format(new Date());


        String textBlock =      programmKonstanteService.getValueOf(ProgrammKonstanten.EMAIL_SIGNATUR);
        String kontrollMail =   programmKonstanteService.getValueOf(ProgrammKonstanten.EMAIL_KONTROLLADRESSE);

        if (S.isEmpty(textBlock)) {
            textBlock = "<kein Text>";
        }

        if (S.isEmpty(eMailTarget) || S.isEmpty(betreff) || S.isEmpty(textBlock) || anlage == null || !anlage.exists()) {
            this.showNotification("FEHLER: Es muss eine mail-Adresse, ein Betreff, ein Textblock und eine Anlage vorhanden sein !!");
        } else {
            try {

                String targetBlock = eMailTarget;
                if (S.isFull(kontrollMail)) {
                    targetBlock=targetBlock+","+kontrollMail;
                }

                Path path = Paths.get(anlage.getAbsolutePath());
                EmailAttachment attach = new EmailAttachment(Files.readAllBytes(path), fileName);

                EmailInfo emailInfo = new EmailInfo(
                        targetBlock,
                        betreff,
                        null,
                        textBlock,
                        attach);

                emailService.sendEmail(emailInfo);
                showNotification("OK: eMail an " + eMailTarget + " erfolgreich versendet !");

                //hier wird die eMail im kopf vermekrt
                Date sendDate = new Date();
                this.getKopf().setLetzterEmailVersand(sendDate);
                this.getKopf().setLetzteEmailVersandAdresse(eMailTarget);
                String versandProtokoll = S.NN(this.getKopf().getEmailVersandVerlauf(),"");
                SimpleDateFormat date_format = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
                versandProtokoll=versandProtokoll+belegTyp.getTypReadable()+" / "+date_format.format(sendDate)+" / "+targetBlock+"\n\n";
                this.getKopf().setEmailVersandVerlauf(versandProtokoll);
                this.auftragKopfsDs.commit();


            } catch (IOException e) {
                e.printStackTrace();
                showNotification("Fehler: " + e.getLocalizedMessage());
            } catch (EmailException e) {
                e.printStackTrace();
                showNotification("Fehler: " + e.getMessage());
            }
        }

    }

    return bRet;
}

Thanks,

Martin

Hi,
Thank you for the sample PDF-attachment. It helped us to find the following issue: link.

Which DBMS do you use? MySQL?
If yes, you are facing exactly that problem.

Regards.

Hi,

yes, its mySQL.
I am storing my attached files in another way (direct in the filesystem).
So for me it would help, when there is a way to save the email-log without storing the attachemets .
Is this possible ?

Thanks

Hi,
It seems it is better to fix the problem locally:
Using DBMS manager alter the “content” column in “sys_sending_attachment”. Change its type to “longblob” and email history will be saved successfully.

Regards.

Hi,

Thanks, I will do this.

Hi,
You can also setup storage of email attachments in filesystem instead of DB.
To do it, set cuba.email.useFileStorage property to true.
But you should upgrade your project to the platform version 6.8.6(or greater). As in earlier versions, this option did not work properly due to the issue.