This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Use Builtin(MAIL_START) To_Get(#FW_RETCD)
Use Builtin(MAIL_SET_SUBJECT) With_Args(#EMAILSBJ) To_Get(#FW_RETCD)
Use Builtin(MAIL_ADD_ORIGINATOR) With_Args(#EMAILFROM) To_Get(#FW_RETCD)
Use Builtin(MAIL_ADD_RECIPIENT) With_Args(TO #EMAILTO) To_Get(#FW_RETCD)
Use Builtin(MAIL_ADD_TEXT) With_Args(#EMAILMSG) To_Get(#FW_RETCD)
If Cond(#EMAILRTNM <> ' ')
Use Builtin(MAIL_ADD_ATTACHMENT) With_Args(#EMAILRTNM)
Endif
Use Builtin(MAIL_SEND) To_Get(#FW_RETCD)
My problem is this: The field #EMAILRTNM is the file location & name of the report I want to attach to my email. The location I have in the above code is an IFS directory. The email sends but without the attachment. What am I doing wrong?
Job Log says "E-Mail message sent". It sends the email correctly - but without the attachment. Apparently after you execute the "MAIL_START" command if any of the following commands error out you have to re-issue the "MAIL_START" before executing the "MAIL_SEND" command otherwise it fails. I found that out in testing <grin>.
Yes I can do a DSPLNK ''/emaildocs/CHAD.PDF' from a 5250 session.
Right or Wrong - Here is my working solution. I canned the Lansa Mail BIF (I got the attachment to work but it would send as garbage - I think there was some encoding issues) that I had previously put and I found this nifty utility on the iSeries called "SNDSMTPEMM" http://www-01.ibm.com/support/docview.w ... s8N1011153. I take my input parameters for To, From, Subject, Attachments, etc.. and I build a string.
#EMAILFROM is just a copy of the email to the person who sent the thing. Make sure you have the Subject & Note in Quotations.
I then execute a "EXEC_OS400" command with the built string.
One tidbit for anyone who wants to use this approach is to make sure you have the AS400 user who will be sending the email in the System Alias Table >> GO TCPADM > #2 'Configure TCP/IP applications' > #12 'Configure SMTP' > #1 'Work with system alias table'
Again - this is good for emailing any document from the iSeries IFS.
I have recently used this BIF successfully. I seem to remember having an issue with the attachment, and adding the second argument (the attachment name) resolved the issue. I could be wrong, but my RDMLX looks like the following: