Attach PDF (no crystal) through code to Email Workflow Event type

SUGGESTED

Hello,

Prior validating payment on Bank website, we need to submit Invoices in PDF.

We would like to avoid send them manually.

  • On X3, we have a folder PIH for Purchase Invoice with all PDF inside named NUM.PDF (Invoice number).
  • In GESPAY (payment), we pick several Purchase Invoices NUM, line by line for 1 payment

We would like to Call a script upon Event (Creation, Button) in GESPAY : 

  • To send the different lines of NUM.PDF by email : 1 email with 1 PDF per line. I don't success
  • 1 payment with 5 invoices lines = 5 emails (Each email 1 PDF)

**

I read different articles on meladx, sendmail, filename, gfilpath, tmp folder. I am lost how to proceed.

I know how to send a Print by email through code with gfilpath.

But I am missing something to send an existing PDF (already on server not a print) by email through code. I got empty PDF files.

If any help would appreciate.

  • 0

    We use workflow rules for that, mentioning a variable on the attach file. Then before calling the workflow in the 4GL code we populate the variable with the file path. I think it is limited to one file per email.

  • 0 in reply to Martins de Almeida

    Thank you. I will test that. I think I have an issue with path / filename.

    It think it is possible to put several files per email. I already did in GESSDH based on LOT field but the 3 pdf came empty.

  • 0 in reply to Martins de Almeida

    I cannot find it. I don t remember well. I will send.

    from memory :

    subprog send_pdf(ysdhnum)

    Blablabla 
    GFILPATH=APDF (delivery note from crea_pdf)

    XGFILPATH=BPDF (coldstore documents from server files)

    Call workflow (...) from awrk

    Blablabla

    In workflow event with GFILPATH’’;’´XGFILPATH

  • 0 in reply to Martins de Almeida
    SUGGESTED

    Hello Martins,

    We developed some programs like you need for our client for many ways.

    Maybe you can use this script

    #ENVIO DE EMAIL
    Local Char DESTINATARIO(100)(1..10)
    Local Integer TIPO_DESTINATARIO(1..10)
    Local Integer YUSR_SUIVI(1..10) #sempre 1
    Local Integer YUSR_NB
    Local Char YTEXTE2(250)
    Local Char YASSUNTO(250)
    Local Char ANEXOS(250)(1..10)
    Local Integer N

    #quantidade de usuário para envio do email(email do cliente)
    YUSR_NB = 2

    DESTINATARIO(1)=[F:YREP]YRELATEMAIL : TIPO_DESTINATARIO(1) = 2 : YUSR_SUIVI(1) = 1

    #infbox [F:YREP]YRELATEMAIL
    ANEXOS(1)=DESTINO

    YTEXTE2=[F:YREP]REPNAM + ' , bom dia, segue relatorio de comissão em anexo. Em caso de duvida favor contatar a Carolina copiada nesse email'

    YASSUNTO='Relatorio mensal de comissão'
    N=1

    ENVOI_MAIL(2,1,0,'ADMIN',"","","","",0,DESTINATARIO,TIPO_DESTINATARIO,YUSR_SUIVI,YUSR_NB,YTEXTE2,YASSUNTO,ANEXOS,N,"",0,"") From AWRKMEL

    Where "ANEXOS" is a array of files in server, in your case are PDF reports.

    If you need more help, you can email me or send messagem in Microsoft teams [email protected]

  • 0 in reply to Bruno Silva

    Dear Roberto,

    I was the one trying to do it.

    Martins, Roberto. Obrigado. Merci :-)

    Below a small test.

    Script XTEST3

    Local Integer STA
    Local Integer TRACE
    Local Char FIC_TRACE(250)
    Local Char ISSUERMAIL(250)
    Local Char A_USER(250)(1..)
    Local Char CC_USER(250)(1..)
    Local Char HEADER(250)
    Local Clbfile BODY(0)
    Local Char ATTACHMENTS(250)(1..)

    A_USER(1)="my email"

    HEADER="Email with 2 attachments"
    ISSUERMAIL="issuer email"
    TRACE = 2
    ATTACHMENTS(1)="[TMP]/TIKTAK.rpt"
    ATTACHMENTS(2)="[TMP]/TIKTAC-multiattach.rpt"

    Append BODY , 'blabla'+chr$(10)
    STA =func ASYRMAIL.ASEND_MAIL(GACTX,ISSUERMAIL,A_USER,CC_USER,HEADER,BODY,ATTACHMENTS,TRACE)
    If STA <> [V]CST_AOK Then
    infbox( mess(1163,196,1))
    else
    infbox( "Email sent!")
    Endif

    End