Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Attachment file  (Read 12519 times)
Fadzil M.
Posts: 7


« on: January 24, 2011, 05:05:03 am »

hi,

Currently we are using the code smtp.4gl  to send email from the application.

Do you have any idea on how to insert one/multiple attachments by using the same concept of smtp.4gl that we currently use?

 

Eg :  From the system, user want to attach the document from C:\mydocument folder. Once user click submit button, the system will email the application with the attachment.

 
 

Thank you.


Reuben B.
Four Js
Posts: 1119


« Reply #1 on: January 27, 2011, 04:06:38 am »

hi,

Currently we are using the code smtp.4gl  to send email from the application.

Do you have any idea on how to insert one/multiple attachments by using the same concept of smtp.4gl that we currently use?

 

Eg :  From the system, user want to attach the document from C:\mydocument folder. Once user click submit button, the system will email the application with the attachment.

 
 

Thank you.




I've asked for your post to be moved to this forum as I know from the information you have provided to Ben in our Malaysia support office that you are using the Genero Web Client and the difficulty you have is in using the Genero Web Client to send an email using an attachment selected by the end-user.  It is nothing to do at all with the use of Genero Studio which is what forum you originally posted.

Also you refer to some code smtp.4gl but you didn't attach it so it is a little difficult for others to see what you are currently doing.  However what was sent into support, I'd say it was based on the code in this example http://code.google.com/p/sourcefourjs/wiki/ABasicSMTPClient

That code uses sockets to communicate with a SMTP mail Server using the SMTP protocol.  As I understand it the SMTP protocol MIME encodes any attachments and includes them in the DATA message.  So if you wanted to continue to use the "same concept of smtp.4gl that we currently use", then you would have to get the file from the end users PC to your server, MIME encode it as a string, and include in the smtp_data() call.

To avoid this MIME encoding step, we have suggested you instead use a tool such as mutt on your server which you would then call from your Genero program with a call like

Code
  1. RUN "mutt -s subject -a attachment.pdf foo@foobar.com < body.txt"

... much simpler than encoding any attachments and constructing the data segment of an SMTP message.

Both techniques require the attachment file to be on the back-end server where the fglrun process is running.  Using the GWC to get the user to select a file on their PC, and transfer it to the server involves the steps illustrated here https://4js.com/online_documentation/fjs-gas-2.30.02-manual-html/User/FileXFerGWC.html#GWC_FGL_GETFILE.

Remembering that with the GWC we are restricted in that we can only do on the front-end what a browser will allow.  A browser won't allow the file selection dialog box to suddenly appear, the user has to click on the browse button of an input of type file in order for that dialog to appear.  Similarly the browser can't suddenly start copying files from the client to the server using FGL_GETFILE() as it can with the GDC.  Hence the step above copies the selected file to a temporary directory where FGL_GETFILE() can access the file and copy it.   Similarly the GDC will allow front-calls to communicate with a Mail client on the users PC e.g. Outlook and create and send a message, whilst the browser will not allow that same level of interactivity with another desktop application.  Hence the WinCom, WinMail front-calls that are available on the GDC that can also be used to send a mail which can't be used in a GWC solution.

If anyone else has alternate methods of sending emails with attachments from a GWC application, please share.  That is one of the purposes of these forums, to share techniques to solve common issues such as this.

Reuben 




Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Reuben B.
Four Js
Posts: 1119


« Reply #2 on: January 28, 2011, 12:00:51 am »

hi,

Currently we are using the code smtp.4gl  to send email from the application.

Do you have any idea on how to insert one/multiple attachments by using the same concept of smtp.4gl that we currently use?

 

Eg :  From the system, user want to attach the document from C:\mydocument folder. Once user click submit button, the system will email the application with the attachment.

 
 

Thank you.




Hi Fadzil,

Another member of our worldwide support community (thanks Florencia) has pointed out to me that the code in one of our demo programs $FGLDIR/demo/MultipleDialogs/Mailer.4gl has 4gl code to include attachments when communicating with a SMTP Server.  If you look inside the function genmail() you'll see the steps it takes to encode the file for sending to the SMTP mail server as an attachment. 

That demo program has been designed to work with GDC and if you wanted to run it in GWC, you'd have to amend the ON ACTION attachfile to avoid using the unsupported front-call https://4js.com/online_documentation/fjs-gas-2.30.02-manual-html/User/FileXFerGWC.html#GWC_FGL_GETFILE.

Reuben


Reuben

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines