Send e-mails with attached Word and Excel templates

This tip is based on the idea to command a Windows listening program from iSeries.

This tip is based on the idea to command a Windows listening program from iSeries. The reaction of the listening...

program is to call programs according to the request and with parameters the sentence of the request. The programs that are existed out of the iSeries environment are used, when these are more suitable to run specific processes.

This tip takes advantage of the tip Start NT/2000 programs from iSeries and can be used in cases you have to send by e-mail Word or/and Excel templates, with minimal handling and with no any restriction of the client environment, you can send the e-mail from a dummy terminal, a telnet session, remote FTP, etc. We achieve the minimal handling with sockets, that is a way to send a request from iSeries program to a Windows server listener program telling to react, according to the request. The formation of the documents is plenty, because the templates are designable, can be processed with the power of Visual Basic for Applications and because the iSeries data, using Visual Basic and CA Express OLE DB driver, are extracted from programmable record sets.

Serializing the programs of the tip, firstly is started on an iSeries program in order to store data, or spool files to a physical file. Then the iSeries program is started, which is responsible to request a command to the NT/2000 server listener service. The service parses the requests and activates the Windows NT/2000 program, sample of which we are presented, in order to create the documents and send the message. Samples of the first two programs are presented in the tip Start NT/2000 programs from iSeries.

In our sample, the syntax of the request is like the formal sentence MAIL<physical file>, <e-mail address>, <iSeries user name> with the meaning to transfer the record set of the physical file in an Excel and Word template documents, to e-mail to the given address and to send a message to the iSeries user session about the completion of the process. In order to use the samples of the tip Start NT/2000 programs from iSeries you must change the value of the request from "SalesForce" to a sentence like that "MAIL,qgpl.pfile,name@domain.com,user400".

Serializing the programs of our sample, firstly is started an iSeries program from a user in order to store data, or spool files to a physical file. Then the iSeries program is started, which is responsible to request the sentence MAIL, <physical file>, <e-mail address>, <iseries user name> to the NT/2000 server listening service. The service, from the token MAIL, understands that it must be called the program we are presented, with the 3 parameters from the residual sentence. That program using Visual Basic and CA Express OLE DB driver connects to iSeries, creates the Word and Excel documents, creates a message, attaches the documents to the message and then sends the message. During the document processing there is always a path to unlock any mutual exclusive iSeries objects and to send status messages to the iSeries user.

The required software to run our sample is the OLE DB driver of CA Express and the MS Outlook with a profile to send e-mails.

In order to create the Visual Basic project, start a new standard project, add a module and delete the form, add the Visual Basic for applications component, Word and Excel 9 object Libraries, ADO 2.0 Library and CDO 1.2 Library. Then copy the source to the module. You must take care to update in the source code the correct path of the document templates and also to update the Outlook profile name as this is configured on the server.

You can also run the presented sample as autonomous program on any client which has the required software, passing as parameters the sentence with syntax <physical file>, <e-mail address>, <iSeries user name>.


 

Click here to view the documents and messages creator program.

================================== MORE INFORMATION ON THIS TOPIC ==================================

The Best Web Links: tips, tutorials and more.

Ask your programming questions--or help out your peers by answering them--in our live discussion forums.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.

This was last published in July 2002

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close