The subject matter of this post compliments the previous post Zipping files in the IFS, which describes how to copy a file to the IFS and zip it in preparation for sending it via email.
Until recently it was not possible to email a file from the IFS without using a third party tool or an API. There is the command SNDDST that I have used to send emails from an IBM i (AS400) with the contents of files or files located in the QDLS file system as attachments. But it cannot access the IFS.
A new command SNDSMTPEMM has been introduced, via PTF, to IBM i 6.1 and 7.1 that allows you to email a file from the IFS as an attachment.
The first screen of parameters is fairly obvious what they are for. The exception, perhaps, being the "Type" which I have selected the email address to be the primary receipient.
Send SMTP E-mail (SNDSMTPEMM) |
The second screen of parameters is where I enter the details for the attachment. In this example I am going to send the file I zipped in Zipping files in the IFS. The "Content type" is *ZIP as the file being attached is a zipped file, I will describe below the valid values for this parameter below. The "TYPE" is *BIN as the zipped file is a binary rather than a text, *TXT, file. The other parameters I leave with their defaults.
Send SMTP E-mail (SNDSMTPEMM) |
The only parameter on the third screen can be ignored.
|
The valid "Content type" values is extensive and covers a lot of the file types I would send from an IBM i, and some I probably would not:
| Content type | Description |
| *OCTET | Octet-stream |
| *PLAIN | Plain text |
| *HTML | XML |
| *RTF | rtf |
| Adobe pdf | |
| *VISIO | Visio |
| *ZIP | Zip files |
| *POST | Postscript |
| *L123 | Lotus-1-2-3 |
| *FREE | Lotus Freelance |
| *WORDPRO | Lotus Wordpro |
| *WORD | Microsoft Word |
| *POWERPT | Microsoft PowerPoint |
| *EXCEL | Microsoft Excel |
| *AC3 | Audio ac3 |
| *MP3 | Audio mp3 |
| *WAV | Audio wav |
| *GIF | Image gif |
| *BMP | Image bmp |
| *JPEG | Image jpeg |
| *PNG | Image png |
| *MPEG | Video mpeg |
| *MSG | Message (rfc822) |
| *OGG | Codec compressed mulitmedia file |
| character-value | A valid IANA registered MIME type. Up to 60 characters can be specified. |
If I was to send the unzipped file then I would change the "Content type" to *PLAIN, and the "TYPE" to *TXT:
SNDSMTPEMM RCP((my-address@email.com)) + |
If you wanted to send the email to multiple people you would need to use the TYPE parameter like this:
SNDSMTPEMM RCP((jane@email.com *PRI) + |
*PRI = primary recpients. In the above example that is Jane and Mary.
*CC = copy. I have copied Emma.
*BCC = blind copy. I have sent myself a blind copy for my records.
One thing I did find when using this command is that when the file I was sending became a certain size the email received would no longer have the attachment, but I would get several emails containing, only what I can describe as, garbage.
The helpful person at IBM Support explained to be that I had to change the message split size for POP (= Post Office Protocol). Then stop the SMTP sever, stop and start the Mail Server Framework, and start SMTP server. These are the commands I ran:
CHGPOPA MSGSPLIT(*NOMAX)Wait a few seconds STRMSF |
After waiting a few seconds for the Mail Server Framework and SMTP server to complete starting I could use the STRSMTPEMM command again.
At the time this post was written there is no Help for this command. Therefore, I have included IBM's technical document and their README file in the links below.
SNDSMTPEMM command
CHGPOPA> command
SNDDST command




