send report as attachment

SOLVED

Hello,

I would like to know if it is possible to send a report (PDF) by email from sage X3 while allowing the user to personalize the email (subject, message, recipients...).

I made a script that automatically generates the invoice in pdf format to save it in a folder when the user validates an invoice. The goal here would be to send this pdf by email as well.

I was thinking of a feature similar to "mailto:" that would allow me to call an outlook window with the report attached.

Thanks in advance for your help

  • +1
    verified answer

    You can use a simple workflow to accomplish this. The workflow event would be SIH and the attachment of the workflow would be pointing to the pdf created in your script. You can check off that the workflow can be edited, hence it would open the workflow screen for the user to edit the email body and the recipients.    

  • 0 in reply to IsraelBraunfeld

    Hello, thank you for your answer !

    It seems to work pretty well.

    Is there a way to send multiple file through a single workflow ? I added my invoice's pdf in Attached document  field (D:\Myserver\invoices\num.pdf" ) but I can't manage to find how to add a second attachment

    Thanks

  • 0 in reply to N2XF3
    SUGGESTED

    You can use an entry point to AWRKMEL using the EMAIL Action and set the EXP_MAIL variable to whatever email you want the sender to be. Years ago, I added a field to the workflow rules where we can specify who the sender should be for that workflow. Then in the entry point I assign to EXP_MAIL the value of that field, if it’s blank then we don’t do anything.  

  • 0 in reply to N2XF3
    SUGGESTED

    In email I saw you had a question regarding sender here I see your question is regarding multiple attachments. Did you delete the previous question?
    Regarding this question I think the you can use a semicolon.

  • 0 in reply to IsraelBraunfeld

    Thanks for your answer, indeed I deleted my question about sender because it was a mistake on my part and there was actually no problem.

    Regarding the semicolon, I did try this but I get the following message:

    Incorrect Expression
    Illegal Character

    here is my field:

    "D:\MYCOMPANY\tmp\"+"Invoice_"+[M:SIH0]NUM+".pdf";"D:\MYCOMPANY\test.txt"


  • +1 in reply to N2XF3
    verified answer

    Found the solution, here is the right way to do it:


    "D:\MYCOMPANY\tmp\"+"Invoice_"+[M:SIH0]NUM+".pdf"+";"+"D:\MYCOMPANY\test.txt"

    So to put it in a nutshell,

    1) SPESIH: When an invoice is validated, the report is printed in D:\MYCOMPANY\tmp\[M:SIH0]NUM.pdf

    (AVANTBOUT is used)

    2) Worflow is called, it retrieve the PDF by "reconstructing" the file name (see the attachment field above)

    I bet there must be an easier / lighter way to retrieve the pdf ? but for now it's the best I can come up with