output report to pdf and attach to mail
Aldevinas Katkus
5-7-21
Operating system: Windows
I would like to attach a report when I create an email from the sales invoice.
So I modified CreateMailFromIVD()
and added a code to generate a PDF report, but it works strange:


In single user mode it attaches only my report PDF to the mail (it should attach an invoice and my report pdfs), even though I can see both PDFs are created in the tmp directory.

In client server mode it crashes the server and does not attach anything.
What is the proper way to create and attach report (not document) to the record?

windows client, linux server

My code:
...
RecordClear(RepSpec);
RepSpec.repname = "MyRn";
ReportDefaults(RepSpec,"MyRClass");
...
SetDocumentFileName(fname);

RepSpec.Media = mtPdf;
SetMedia(mtPdf);
//RunReport(RepSpec,0);
MyRn(RepSpec);//tried to call report instead of RunReport, same result
SetDocumentFilename("");
if (FileExists(fname)) then begin
RecordLinkFile(fname,0,Mailr,CurrentCompany);
Delete_File(fname);

SetDocumentFilename("");
end;

hansa.log
2021-05-06 18:28:47 (1) AK Printing Faktūros 20210111
2021-05-06 18:28:47 (1) AK PDF Error: 4133
...

2021-05-06 18:28:47 (1) AK PDF Error: 4133

2021-05-06 18:28:47 (1) AK backtrace called due to: CopyDVP with some KeyMasterArrType touchedf!=false
2021-05-06 18:28:47 (1) AK -------------------- backtrace start -------------------------
2021-05-06 18:28:47 (1) AK 0: /home/stabilus/ss/StandardERPServer64() [0x6a4838]
...
2021-05-06 18:28:47 (1) AK 22: /home/stabilus/ss/StandardERPServer64() [0x40a942]
2021-05-06 18:28:47 (1) AK 23: /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f3eb669db35]
2021-05-06 18:28:47 (1) AK 24: /home/stabilus/ss/StandardERPServer64() [0x40a9e1]
2021-05-06 18:28:47 (1) AK --------------------- backtrace end --------------------------
2021-05-06 18:28:47 (1) AK
2021-05-06 18:28:47 (1) AK dump of call stack
2021-05-06 18:28:47 (1) AK Exiting to protect the database



Leave Comment
You can subscribe to notifications for this post by selecting the 'star' icon on the top right corner of the post.
Latest Posts
Hi there, Server – tried both Windows Server 2022 and Linux Version - 2025-08-11 and 2026-05-25 We were testing a new version (2025-08-11) with a Halcust that we had migrated from the existing ...
10:11 4 Aug 2026
Kevin Stepper
Hi, years ago we used to have the email and conference module. Did not need it so we dropped it. We hav recently implemented global users, which are all named users and therefor seem to need a m...
18:07 3 Aug 2026