Home > AS/400 Tips > iSeries programmer tips > Send spreadsheets from AS/400 via e-mail
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ISERIES PROGRAMMER TIPS

Send spreadsheets from AS/400 via e-mail


Mike Tillison
01.08.2001
Rating: -3.89- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


It is possible to send a spreadsheet from the AS/400 via e-mail as an attachment. The following example uses a Qry/400 output file, but it could just as easily be done with a program output file, or Opnqryf output. There are a few simple rules to follow:

1. Each field within the file must be separated by a ',' (comma). In Qry/400, this can be done by defining result fields such as COM1, COM2, COM3, etc. -- each having an expression of ',' and placing these in between your data fields.

2. Numeric fields MUST be Zoned Decimal, NOT Packed. To do this in Qry/400, just use the field in a calculation. Define a Result field and use the file field in the expression, e.g. add zero to it or multiply by 1. Then use the Result field in the output file. Make SURE you specify a length for the Result field otherwise it will pack it. 'Summary' Result fields are always Zoned Decimal.

Once the file has been created, you need to convert it to ASCII by copying it to an AS/400 folder with the following command:

/* COPY THE FILE TO A PC DOC  */                           
             CPYTOPCD   FROMFILE(MYFILE) TOFLR(MYFOLDER) + 
                          TODOC(MYFILE.CSV) REPLACE(*YES) 

The 'TODOC' name can be any name, but it must have the prefix '.CSV', which is a file extension of 'Comma Separated Values'.

Now, send it as an e-mail attachment with the following command:

SNDDST Type(*DOC) TOINTNET((me@pfizer.com)) + 
         DSTD('This is my Email Function') MSG('Attached is the data + 
                You requested') IMPORTANCE(*HIGH) + 
                DOC(MYFILE.CSV) FLR(MYFOLDER) 

The Recipient will get an e-mail message stating 'Attached is the data you requested,' along with the attached file called MYFILE.CSV.

When opened in Excel, there's all your data in nice neat rows and columns. (It should work the same in Lotus).

Comments and caveats

There is an obvious chance that you may have commas embedded within your text fields, which will skew the data columns in the spreadsheet. To prevent this, I wrote a small RPG program to convert any of these embedded commas to 'blank' before it gets converted to the folder.

There is a setting on the 400 that dictates how large a message can be. If this is set too small, your attachment will be sliced and diced into multiple garbled e-mail messages.

Check your POP Server Attributes (CHGPOPA) or see the IBM Support document, reference number 862565c2007cda23 for the fix.

The SNDDST can send to AS/400 user IDs as long as their SMTP addresses has been entered in the Directory Entries. The User ID will resolve to the actual SMTP address.


Rate this Tip
To rate tips, you must be a member of Search400.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
RPG iSeries programming
How to: Sort arrays using RPGIV
How to: Create an RPGLE array
How to use an embedded SQL statement and display the result in a subfile
Eight steps for creating program documentation using AS/400 utilities
Application modernization for the iSeries: Why bother?
RPG application gets a Web revamp at Pinnacle Foods
There is very little RPG on System i can't do: From RPG nay to RPG yay!
Chain operation error after converting RPG3 to ILE RPG (RPGIV)
RPG application modernization for i5
RPG dynamic value calculation versus hard-coded values

iSeries ILE programming
How to use an embedded SQL statement and display the result in a subfile
Eight steps for creating program documentation using AS/400 utilities
Searching fields for values
Searching part of a name or address in AS/400
Top 10 programmer tips YTD
How to use the binder language to manage service programs -- Part 3: Examples and pitfalls
Top 10 programmer tips of 2005
How to use the binder language to manage service programs -- Part 2: Understanding the binder language
How to use the binder language to manage service programs -- Part 1: Service program signatures
Display attributes made simple

iSeries programmer tips
What is an integrated database?
An automated CL method of moving a query from AS/400 to Excel
Using SQL on System i to create multicolored comment lines
Eight steps for creating program documentation using AS/400 utilities
DAYSPAST CLLE program for AS/400: Compares object creation date with today's date
Coloring source lines with COBOL and using a shortcut from within PDM
Date calculation commands for AS/400
There is very little RPG on System i can't do: From RPG nay to RPG yay!
Using SQL on System i to color source code and inline comments
Controlling spool files with APIs

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
Report Program Generator  (Search400.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



iSeries Security - Security Tools, Physical Security and System Security
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 1999 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts