Send Email with PDF Output

First and foremost check is to see that the JDE.ini has been setup with settings to mail with the SMTP settings in it, and that your SMTP allows the service.
JDE.ini – [JDEMAIL] settings needs to be configured as
1Rule1=90|OPT|MAILSERVER=SMTPSRVRNMATL20

E-MailTo check your SMTP services status use Telnet (needs Admin priv)
Open Telnet
Host Name = SMTP Servername
Port = smtp
Termtype = what ever it defaults

It will give you SMTP Server status

To know more about JDE.INI visit – http://www.scribd.com/doc/2088833/JDE-ini

Step 1 –
Create new Driver UBE which will then call the UBE who’s output has to be E-Mailed.
Step 2 –
After the above is done. We need to get the JobNumber of the executed UBE, to retrieve the PDF from the ExecutionHost server. So we need to use the PATH to the Server Print queue and the output file name.
The Usual PDF Output naming format is: R551234_VERSION_JOBNUMBER_PDF (If output in UNIX servers) else use .PDF
Please visit the link to see how to retrieve the Server JobNumber
Step 3 –
Once the full PATH is generated use BF B0500190 (SendEMailHRM) to use the file as attachment and send to respective person(s).

From Version 8.10 and above, the Send Email HRM BSFN has been replaced with B0500725 – Email Merge Letter, details of which has been written in the comments by Matt

Shown below is a sample code of what the parameters are for the B0500190 (SendEMailHRM).


VA rpt_MessageText = "Message text"
VA rpt_Subject = "Subject Text"

//GET THE JOBNUMBER for the UBE using above said Logic
//Lets say Retrieved rpt_ServerJobNumber
//
VA rpt_AttachFileName = concat("PATH",concat(rtrim(ReportName,' '),concat("_",concat(rtrim(VersionName,' '),concat("_",concat(rtrim([VA rpt_ServerJobNumber],' '),"_PDF"))))))
VA rpt_AttachDesc = concat(rtrim(ReportName," "),concat("_",concat(rtrim(versionname," "),".PDF" ) ) )
//
RV FileName = VA rpt_AttachFileName
//
If VA rpt_ServerJobNumber is greater than
//
Send E-Mail - HRM

    “JDE_System@jdedwards.com” -> szFrom
    VA rpt_All_To_ID -> szTo
    VA rpt_All_CC_ID -> szCC
    VA rpt_Subject -> szSubject
    VA rpt_MessageText -> szMessageTextChar256
    “1” -> cIncludeAttachmentFlag01
    VA rpt_AttachFileName -> szNameOfAttachmentFile
    VA rpt_AttachDesc -> szAttachmentDisplayText
    UNDEFINED -> cSendCopyOfEMailToSelfFlag01
    UNDEFINED -> cSetOneWorldErrorFlag01
    UNDEFINED -> cRecordOperInLogFileFlag01
    UNDEFINED -> cAppenOrOverwriteLogFile01
    UNDEFINED -> szNameOfLogFile
    RV Variable 000006 <- mnErrorCodeReturned

End If

The Problem with the above BSFN is that the attachment file path can not be greater than 40 Chars. So we may need to copy the BSFN to replace the DD Item with something of atleast 256 chars in length.

You may love to read the following document for more information – JDE-Email-Settings

26 thoughts on “Send Email with PDF Output

  1. Marcellus Palomino Reply

    This is the best technique to be followed, I must say that really being here and not using this will really be silly. Will you please reply with more information here? I think you have a good response and it will definitely help a lot. As this forum has really been a good platform for us all, contributing to this will really be healthy for our and your business as well. We all are waiting for a good informative response. Thanks a lot for this, waiting for more.

  2. Deepak C Thali Reply

    Hi Deepesh,
    I am deepak currently working in Dubai,UAE. I would like to clarify some points about upgrading tools release. Now we are on tools 8.96.3 and would like to upgrade to 8.97.3 which is running on iseries. If possible can you please tell me how can we run multifoundation on as400 and incase if we have to revert to 8.96 what changes required on deployment server?
    deepak

  3. Matt Reply

    Hi,
    Will this work on the JDE scheduler -> if I schedule the driver report and run it overnight can I expect it will work?
    For instance retrieving the job number is usually user specific – so with the scheduler what will happen?
    Cheers
    Matt

    • Deepesh Divakaran Post authorReply

      Hi Matt,
      What I understand is, we can setup a Job with respect to a User in the JDE Scheduler, so there it goes. Anyways, this works with Scheduler too, but that, you will need to code around to set the e-mail Id’s coming on correctly.
      What we did in our company is – We got a subsystem job which runs every 5 mins and picks up those UBE Outputs which have been entered in a table having UBE names/versions for specific user/role and the To E-Mail address. The Subsystem UBE then picks up those UBE outputs (set in table) being run in the past 5 mins, and e-mails it them to the eMail address only if it was run by the User/Role as setup in the Table. This way we need not create the above said logic for every UBE we code. All we need is a Record in the Table.
      Hope I make sense.

  4. Matt Reply

    Hi Deepesh,
    Thanks for that – I’m going to give it a shot!
    Also, do you know a business function that allows me to dynamically call any UBE (from say a processing option?).
    Basically I don’t want to use the report interconnect because I don’t want to hardcode which report I’m going to be running.
    I’ve tried one BSFN called “Call User Defined UBE” -> but no luck! – as always the documentation attached to the standard code base is pathetic!
    Cheers
    Matt

  5. Matt Reply

    Hi Deepesh,
    I got it all going in DV and PY – then it hit PD… no go – when you run the UBE to email the PDF’s as suggested it hits a problem – the Send E-Mail – HRM is defined as a client only business function – so it will not run in a UBE.
    Back up plan?
    Cheers
    Matt

    • Deepesh Divakaran Post authorReply

      Matt,
      I’m sorry my mistake… We had created a BSFN to do the e-mail part on server. following is the logic of the BSFN
      Used “Execute External Program” (B34A1030) and create a Send E-Mail string to get it working with your server OS. Like if, your Server OS is Linux/Unix use the MailX command to send the attachment. Prefix ‘uuencode’ for the file, if its Unix.
      e.g. SendString = (uuencode $SVRHOME/PrintQueue/R550101_VER001) | mailx -s SUBJECT -a $SVRHOME/PrintQueue/R550101_VER001_PDF.pdf ORIGINHOSTNAME
      Hope that helps.

  6. Matt Reply

    I forgot to mention it worked in DV and PY because I ran it locally (ie client side).
    Cheers
    Matt

  7. Matt Reply

    Hi Deepesh,
    Just thought I’d update you with a BSFN I found that sends emails with attachments off of the server!
    B0500725 – Specifically “Email Merge Letter”.
    Just tested in PY all good! Saves me having to write the unix script 😉
    Cheers
    Matt

    • Deepesh Divakaran Post authorReply

      Matt,
      That’s great, this BSFN does not exist in Xe (the system I’ve access to). Could you help with the BSFN parameters/usage. I would love to update this article & if you are interested, you could do that too, and write/update new JDE articles.

  8. Matt Reply

    B0500725 – Email Merge Letter
    Here is the usage – where I have defined literals below with quotes you can simply use a variable to parse in dynamic email addresses/filenames etc. For the path I retrieve it from the processing options of the UBE.
    “FromEmail@address.com” -> szFrom
    “ToEmail@address.com” -> szTo
    -> szCC
    “SubjectString” -> szSubject
    “MessageString” -> szMessageTextChar256
    “1” -> cIncludeAttachmentFlag01 (leave blank if no attachment)
    “\\ServerWherePrintJobsSit\printqueue\” -> szNameOfAttachmentFile (leave blank if no attachment)
    “filename.pdf” -> szAttachmentDisplayText (leave blank if no attachment)
    Everything else is blank -> unless you want the error code back.
    When setting this up you’ll no doubt hit issues – for instance SMTP errors, ini file errors, path errors. The best thing to do is set it up in your UBE – run it locally with debug logging turned on. To avoid filling your log up with crap use owdlc.exe, simply go to batch versions, select your report/version/processing options/data selection and before clicking OK to run the report locally simply click debug on in owdlc.exe… this way the log only has entries from running the UBE. Then to quickly find what happened when you called the business function do a find/search on the debug.log file search for your email address (remember the email address is passed into the function) so it will be present in the debug log. Just under it you can see any errors.
    Types of errors you get are:
    Email server doesn’t trust your IP address (check with your email admin you’re on a trusted source).
    Email address is spoofed – (get your email admin team to allow your IP address to create/send emails).
    Incorrect port number – just use the standard 25 – from what I’ve seen it’s easier to change your email server than it is JDE on this one (you can do it, but it’s a pain)
    Invalid path (check the path you’ve passed to the function and simply cut/paste it into windows explorer and see if you can get there – if you can’t then chances are neither can the BSFN – also remember to make sure the server where this will run has access to this path.
    That’s pretty much it.
    Good luck.
    Cheers
    Matt

  9. Matt Reply

    Hi Joyce,
    What version of JDE are you using it on?
    Cheers
    Matt

  10. Krishna Reply

    Hi Deepesh,
    Is it possible to print in the body of the mail, instead as attachemnt after my UBE ran sucessfully.
    Thanks
    Krishna

    • Deepesh Divakaran Post authorReply

      Hi Krishna,
      You can do an FlatFile output as an HTML file, and send that HTML file as the message of the email. The Email will have to be setup to be sent as mime:HTML though.

  11. Ramakrishna AVL Reply

    hi deepesh,
    can u give some guidance for me to learn JDE, iam doing MBA-2nd year.. Which one[either functional or technical] is suitable for me to learn in JDE..how to get basic materials on JDE. Pls cooperate.
    Thanks

  12. Raj Reply

    Hi,
    My requirement is to send emails with pdf o/p to persons who are responsible.
    My driver report calls the child report on every Level Break header(AN8 in my case).The child report runs based on this AN8 and generates a pdf which will be sent via email.
    I am using Mail Merge Letter(B0500725).Im passing RI AN8 email address here.My problem is that the mail with pdf is going to the next An8 email Address which is generated.Say my driver UBE has 3 An8(100,101,102).An8 100 pdf is going to 101 Email adress and An8 101 pdf is going to 102 address.An8 102 pdf is not going to any one.Im able to see all these jobnames in F986110.
    Thanks in Advance.
    Regards,
    Raj

  13. Sub Reply

    Deepesh,
    I will like to send Statements (R03B500X) and Delinquency notices ( R03B525X) Via email to customers. This will be run on a monthly basis
    Please let me know what are the requirtements from the functional side. whether it should be on a SEPERATE JOB Q, seperate userid is required etc.
    Regards
    Subu

    • Deepesh M Divakaran Post authorReply

      Raj/Subu,
      You will have to do some setup for Emailing to work within JDE. Best option will be to use tools like BI Publisher or Formscape.
      2 ways to achieve your issue in JDE
      First method – to use the option above.
      Second – Need to have one table which will be updated with a email-id and UBE name + Job Number. Secondly, a Sub-Process UBE which will poll this table and will mail the PDF output to the email-id specified in the table.

  14. Sankar Reply

    Hi Deepesh,
    I am also using Send E-Mail – HRM BSFN to send emails. Is there any way to track whether email is read or received?
    What if the recipient mail id is wrong, will it bounce back to sender’s mail id?
    Will this email will be stored anywhere like work center or something?
    Thanks,
    Sankarguru Mani

  15. Bhagyesh Reply

    Hi Deepesh,
    I trid this code with no luck, I mean the UBE used to go in loop. The reason being that the F986110 file is not being populated with my current client who r on XE, can you please enlighten on this issue, as to how can I change setting for F986110.
    With Regards,
    Bhagyesh

Leave a Reply