Monday, 15 April 2013

Simple JDE BSFN to send an email with an attachment

I guess it's exactly what the title suggests, some code to help you.

It's a BSFN that takes a few parameters:

  • to
  • From
  • file to attach
  • name of attachment
  • subject
  • Body
  • CC
  • BCC


The source code can be found here.  It's actually a parfile for a project, you can use this at your site if you are 812 and above, because there is nothing hard about it.  Restore this and build CCUSTOM.dll, it will need to be a full package to work on the server.

The code is super simple, but it might help.  There does not seem to be something totally generic for sending emails with attachments from E1.

Enjoy!

15 comments:

Anonymous said...

what should be the server JDEMAIL settings for jde.ini file

Anonymous said...

The BSFN is working well with the FAT but not working at all on WEB Clients.

Shannon Moir said...

there are many reasons that this might not work on the server. quite common are smtp issues, security and relay etc. You need to make sure the smtp server is configured, and quite often the from address needs to be using your domain. good luck!

Anonymous said...

Hello Shanon,

The JDE server settings is same as FAT client.

What I failed to look out was the B9840521 RetrievePathInformation is cleint only.

Any BSFN which is both Client and Server for JOB Number Retrieval.

Your code is working fine to my mind. Its the Job Number and Path to the submitted job file is the culprit.

Shannon Moir said...

Hello, it seems (from the context) that you are trying to solve the age old problem of emailing the output of a PDF after the job completes - oh what fun!!!

I find the best way to do this is using an OSA. You can attach your OSA to which ever reports you choose (like an OCM) and then either print or email depending on the requirements. I'm pretty sure that I've documented these before in my blog. I've written them to email, print, print twice, print from different trays... print up-side-down - all sorts of cool stuff.

Shannon Moir said...

Hello, it seems (from the context) that you are trying to solve the age old problem of emailing the output of a PDF after the job completes - oh what fun!!!

I find the best way to do this is using an OSA. You can attach your OSA to which ever reports you choose (like an OCM) and then either print or email depending on the requirements. I'm pretty sure that I've documented these before in my blog. I've written them to email, print, print twice, print from different trays... print up-side-down - all sorts of cool stuff.

Anonymous said...

Which post you are refering too. Please give me direct link on comment

Anonymous said...

Hello Sahnnon,

How you are utilisieng this bSFN in APPs or UBE's

Shannon Moir said...

Hi, I use this function in both without any problems.
shannon

Anonymous said...

What is that you use for attaching any ER by example in UBE and Applications. I mean any particular call to location file and set that to parameters

Anonymous said...

My code currently looks like this, working good in FAT. I doubt about the OCM mapping for RetrievePathName and Find a file name string with wild card being type 2 c BSFN on servers. Are there any different ways of useing the BSFN Send Email with attachment

OBJECT: SECTION
EVENT: End Section
-----------------------------------------------------------------------
OPT: Using Defaults
0001 //
0002 VA rpt_EmailClassification_ECLASS = "PMT"
0003 //
0004 RetrievePathName
VA rpt_58_szDirectoryPath_DRPT <- BF szFileorPathToFind
0005 VA rpt_58_szOMWProject_OMWPRJID = "R586666"
0006 VA rpt_58_szOMWObjectVer_OMWVER = "M3000001"
0007 //
0008 VA rpt_58_szExetargetPath_EXEPATH = concat(concat(concat([VA
rpt_58_szOMWProject_OMWPRJID],'_'),[VA rpt_58_szOMWObjectVer_OMWVER]),'_')
0009 VA rpt_58_szExetargetPath_EXEPATH = concat([VA rpt_58_szExetargetPath_EXEPATH],'*.pdf')
0010 VA rpt_58_szExetargetPath_EXEPATH = concat([VA rpt_58_szDirectoryPath_DRPT],[VA
rpt_58_szExetargetPath_EXEPATH])
0011 Find a file name string with wild card
VA rpt_58_szExetargetPath_EXEPATH -> BF szFileorPathToFind
VA rpt_58_szExetargetPath_EXEPATH <- BF szFoundFileorPath
0012 VA rpt_58_szDirectoryPath_DRPT = concat([VA rpt_58_szDirectoryPath_DRPT],[VA
rpt_58_szExetargetPath_EXEPATH])
0013 //
0014 //
0015 Send Email with attachment
"xxxx@xxx.com" -> BF szRPDFDeliveryEMail
" xxxx@xxx.com " -> BF szRPDFDeliveryEMail_2
"E1 Mail System" -> BF szApptSubject
VA rpt_58_szDirectoryPath_DRPT -> BF szCommandString
"Please see the attached file." -> BF szRPDFDeliveryEMail_3
______________________________________________________________________

Unknown said...

Hello Shannon,

I am using this BSFN B0500725 to send email with attachment.Without Attachment, the Email are being sent but with attachment it is failing to even send the email. The Type of file is simple txt and size hardly few kb

thanks,
Satish

Shannon Moir said...

You should be getting something in the logs, you need to find if it's SMTP error codes and work backwards.

Shannon Moir said...

You should be getting something in the logs, you need to find if it's SMTP error codes and work backwards.

Unknown said...

Dear Shannon,
I customized the goods receiver JDE app to send emails once the goods received using B0500725 standard BSFN.
It works perfect when i tested it, but when the users using it it did not send any emails, and i found out it something related to security.
My question is what the specific objects i should give it to the user to give him rights to send the email.

Best Regards,
Ahmed M.Jaser.

Extending JDE to generative AI