PxPlus User Forum

Twitter Twitter Twitter

Author Topic: email received with corrupted pdf file attached  (Read 1628 times)

Sonia Cruz

  • Member
  • **
  • Posts: 12
    • View Profile
email received with corrupted pdf file attached
« on: September 12, 2022, 09:51:18 AM »
Hello All,
I am having a situation that I never had before when sending an email with pdf file attached, where only the pdf file attached is received corrupted (and if several pdf files attached only the first one is corrupted). Does someone have had this situation?  I am using the call “*WEB/email…”.  I did verify the originals pdf report files and they are fine and created properly.  This is in a new linux environment (Ubuntu ver 20.04.4) and with pxplus 2021 Web (Ver: 18.10/Unix-Linux-Ubuntu).

I will appreciate your comments. 

Thanks in advance!

Regards,

Sonia Cruz

Mike King

  • Diamond Member
  • *****
  • Posts: 3830
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: email received with corrupted pdf file attached
« Reply #1 on: September 12, 2022, 09:59:11 AM »
Is this unique to the PDF file or always just the first? 
(i.e. If you change the order of the attachments does the corrupted file follow the specific PDF file or does it remain with the first PDF file?)

Also make sure the PDF file is closed prior sending the email.  We have seen this cause trouble as the CLOSE of the PDF file add additional control information to the file that is needed to read it.
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

Sonia Cruz

  • Member
  • **
  • Posts: 12
    • View Profile
Re: email received with corrupted pdf file attached
« Reply #2 on: September 12, 2022, 11:19:52 AM »
Hello Mike,

I was wrong, I did change the order and discovered that is it not the first pdf, it is the last pdf attached.
I did check and all pdf files are close before included to the attachment$ variable.

Thank you!

Mike King

  • Diamond Member
  • *****
  • Posts: 3830
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: email received with corrupted pdf file attached
« Reply #3 on: September 13, 2022, 04:41:15 PM »
Sonia

We just tried this here using PxPlus 18.10 on ubuntu 20 and it worked using the following program:

0010 BEGIN
0020 FOR pdf=1 TO 5
0030 LET f$="test"+STR(pdf)+".pdf"
0040 ERASE f$,ERR=*NEXT
0050 OPEN (1)"*pdf*;file="+f$
0060 FOR p=1 TO 10
0070 PRINT (1)'FILL'(1,TBL(p|3,"Red","Blue","Green")),'RECTANGLE'(@X(MXC(1)-10),@Y(0),@X(MXC(1)),@Y(2)),
0080 FOR n=1 TO 50
0090 PRINT (1)"This is line number ",n," on page ",p," in file ",pdf
0100 NEXT n
0110 PRINT (1)'FF',
0120 NEXT p ! Next page
0130 CLOSE (1)
0140 LET attach$+=SEP+f$
0150 NEXT pdf
0160 LET from$="your.email@example.com"
0170 LET reply$=""
0180 LET to$=from$
0190 LET cc$=""
0200 LET bcc$=""
0210 LET subject$="This is a test of multiple pdfs"
0220 LET attach$=attach$(2)
0230 LET option$=""
0240 LET smtp$="mail.example.com;465-secure;your.email@example.com;your_email_password"
0250 CALL "*web/email",from$,reply$,to$,cc$,bcc$,subject$,message$,attach$,option$,smtp$,0,0,"",0,errmsg$

The items marked in dark red will need to be adjusted to your email address, server and password.

This test program created/sent an email with 5 PDF files with a mix of plain text and graphics.  When I received the the email all of the PDF files were correct.

Can you advise what is wrong with the final PDF file on your system?  (i.e. What happens when you try to open / look at the final file?)
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

Sonia Cruz

  • Member
  • **
  • Posts: 12
    • View Profile
Re: email received with corrupted pdf file attached
« Reply #4 on: September 13, 2022, 06:13:14 PM »
Hello Mike,
What was happening is that the system was altering the report writing data and including scribbles on top of the information presented in the report originally designed.

The communication ports were changed and we did continue with the same problem where the last pdf file attached is corrupting.  At the level of the operating system everything looks good.

Now with your program sample I noted that it is not included the ?Q at the end of attachment$ variable value.  I did check the pvxplus documentation and it is yet appearing there the ?Q as requirement .  But I did remove and now it works properly.

Thank you so much for your time!


Mike King

  • Diamond Member
  • *****
  • Posts: 3830
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: email received with corrupted pdf file attached
« Reply #5 on: September 13, 2022, 06:21:47 PM »
The ?Q tell the system to use a different format (Quoted-Printable vs Base64).  For binary files such as PDF's I would suggest using the default Base64.

Also the ?Q applies to the file immediately preceding the ? -- not all files.  This is likely why only the last file was impacted.
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com