暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

邮件发送IFS文件(来自Google)

啊皮 2021-08-06
663

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)

Type choices, press Enter.

RECIPIENT:
E-mail address . . . . . . . . > my-address@email.com



Type . . . . . . . . . . . . . *PRI *PRI, *CC, *BCC
+ for more values
SUBJECT . . . . . . . . . . . . > Example of using SNDSMTPEMM

NOTE . . . . . . . . . . . . . . > This area is for the email body text






More...

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)

Type choices, press Enter.

ATTACHMENT:
File name . . . . . . . . . . > MyFolder/extract.zip






Content type . . . . . . . . . > *ZIP

TYPE . . . . . . . . . . . . . *BIN *BIN, *TXT
+ for more values
Character set:
Character set name . . . . . . *UTF8

Character set CCSID . . . . . *DFT 1-65533, *DFT
More...

The only parameter on the third screen can be ignored.


Send SMTP E-mail (SNDSMTPEMM)

Type choices, press Enter.

Password . . . . . . . . . . . .




Bottom

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 typeDescription
*OCTETOctet-stream
*PLAINPlain text
*HTMLXML
*RTFrtf
*PDFAdobe pdf
*VISIOVisio
*ZIPZip files
*POSTPostscript
*L123Lotus-1-2-3
*FREELotus Freelance
*WORDPROLotus Wordpro
*WORDMicrosoft Word
*POWERPTMicrosoft PowerPoint
*EXCELMicrosoft Excel
*AC3Audio ac3
*MP3Audio mp3
*WAVAudio wav
*GIFImage gif
*BMPImage bmp
*JPEGImage jpeg
*PNGImage png
*MPEGVideo mpeg
*MSGMessage (rfc822)


*OGGCodec compressed mulitmedia file
character-valueA 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)) +
SUBJECT('Unzipped extract') +
NOTE('Attached is the unzipped extract file') +
ATTACH(('MyFolder/extract.csv' *PLAIN *TXT))

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) +
(mary@email.com *PRI) +
(emma@email.com *CC) +
(my-address@email.com *BCC)) +
SUBJECT('Unzipped extract')
NOTE('Attached is the unzipped extract file')
ATTACH(('MyFolder/extract.csv' *PLAIN *TXT))
  • *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)
ENDTCPSVR SERVER(*SMTP)
ENDMSF
  Wait a few seconds
   STRMSF
STRTCPSVR SERVER(*SMTP)

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

个人小商城


文章转载自啊皮,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论