<<CUBA Issue>> CONTENT_TEXT_FILE_ID value is not stored sys_sending_message table

Hi,

CONTENT_TEXT_FILE_ID value is not stored sys_sending_message table.

Below piece of code for your reference.

Please suggest why is it not storing CONTENT_TEXT_FILE_ID value in table sys_sending_message

EmailAttachment pdfAttach = new EmailAttachment(pdfBytes, fd.getName(), String.valueOf(fd.getId()).replace("-",""));

                EmailInfo emailInfo = createEmail(thresholdFleet, reminder.getRemValue(), reminder.getRemPercentage(), pdfAttach);

return EmailInfoBuilder.create()
.setAddresses(accountDetailsService.getGPEmailAddresses(thresholdFleet.getOuNum()))
.setCaption("REMINDER EXCEED " + reminderPercentage + "% LIMIT " + thresholdFleet.getCustomerName() + " AS AT " + LocalDate.now())
.setTemplatePath(“com/xyz/rap/templates/” + templateName + “.html”)
.setTemplateParameters(Collections.singletonMap(“thresholdFleet”, thresholdFleet))
.setBodyContentType(EMAILCONTENTTYPE)
.setAttachments(pdfAttach)
.setSendInOneMessage(true)
.build();

Hi,
Email text is stored either in the SendingMessage#contentText (directly in the DB) or in the SendingMessage#contentTextFile (in the file storage through FileDescriptor) attributes.

The behavior is switched by the cuba.email.useFileStorage configuration property (EmailerConfig#isFileStorageUsed)

Hi,

My question is when I send attachment on email how I can store the id value from sys_file table in sys_sending_message or sys_sending_attachment table.

Please share the sample piece of code.

Regards
Zafar

CUBA Emailer does not provide such API. You’ll need to load the file to memory and then pass it to the EmailInfoBuilder.

Hi,

If you look at the below code posted earlier I did the same solution suggested by you.

However I have noticed in CUBA internal source code this value is not persisted.

EmailAttachment pdfAttach = new EmailAttachment(pdfBytes, fd.getName(), String.valueOf(fd.getId()).replace("-",""));

return EmailInfoBuilder.create()
.setAddresses(accountDetailsService.getGPEmailAddresses(thresholdFleet.getOuNum()))
.setCaption("REMINDER EXCEED " + reminderPercentage + "% LIMIT " + thresholdFleet.getCustomerName() + " AS AT " + LocalDate.now())
.setTemplatePath(“com/xyz/rap/templates/” + templateName + “.html”)
.setTemplateParameters(Collections.singletonMap(“thresholdFleet”, thresholdFleet))
.setBodyContentType(EMAILCONTENTTYPE)
.setAttachments(pdfAttach)
.setSendInOneMessage(true)
.build();

do you mean that the value is NULL or the value is different?

The xxx_file_id will not be filled unless cuba.email.useFileStorage is set to true.