Delivering Files from IBM i to Sharepoint with CoolSpools

IBM i Data to SharePoint: SharePoint document folders use a proprietary Microsoft file management system and cannot be accessed in the same way as network file servers, so CoolSpools is prevented from delivering files directly into a SharePoint folder by using an industry standard mechanism such as FTP.

It is still possible to deliver files to a SharePoint using CoolSpools, but you must do so indirectly using a Power Automate flow. The example below shows one way that you can do this. Most of the configuration required is outside of CoolSpools and within Office 365, so we would recommend reviewing the latest Microsoft documentation.

Step 1

Within Office 365 create a shared mailbox that will be used for delivery of files to SharePoint. If required you can create multiple shared mailboxes that will each be used to deliver files to a different SharePoint folder.
Open the Exchange admin center and select Manage Mailboxes (login as an admin user if prompted).
https://admin.exchange.microsoft.com/#/mailboxes

Click Add a shared mailbox and enter a name the new mailbox (e.g. [email protected] replacing domain.com with your domain name).

Step 2

Now we need to create a Power Automate flow. Open Power Automate (login as an admin user if prompted).
https://make.powerautomate.com

Select My Flows from the menu on the left

Click on New Flow, then select type Automated cloud flow

Give the flow a meaningful name (e.g. “Save email attachments to SharePoint”)

Select trigger When a new email arrives in a shared mailbox (V2)

Set the trigger parameters as follows…

  • Original Mailbox Address: [email protected]
  • Importance: Any
  • Only With Attachments: Yes
  • <b?Include Attachments: Yes
  • Folder: Inbox

Now click on the plus symbol underneath the trigger to add a new action

Select the action Apply to each (categorised under Control)

Set the action parameters as follows…

  • Select An Output From Previous StepsL click the lightning symbol and select Attachments

Click the plus symbol inside the Apply to each box to add an action to perform on each attachment, select the action Create file (categorised under SharePoint)

Set the action parameters as follows…

  • Site Address: Select the required SharePoint site from the dropdown list
  • Folder Path: Specify the target document folder within the SharePoint site (e.g. /Reports)
  • File Name: Click the lightning symbol and select Attachment Name
  • File Content: Click the lightning symbol and select Attachment Content

Click on the Save button to save the flow definition and then exit to the main flows page – the new flow is now active.

Step 3

Run the CoolSpools commands to convert IBM i spoolfile reports and data, making sure to use the EMAIL() parameters to send the converted file to the new [email protected] email address, as shown in the examples below.

CVTDBFXLSX FROMFILE(LIBRARY/FILE) TOSTMF(filename.xlsx) EMAIL(*YES) EMAILOPT(*NO ‘Email subject’) EMAILTO(([email protected]))

CVTSPLPDF FROMFILE(SPOOLFILE) TOSTMF(filename.pdf) EMAIL(*YES) EMAILOPT(*NO ‘Email subject’) EMAILTO(([email protected]))

The email attachments that are sent to [email protected] will be automatically processed by the Power Automate flow and saved to the SharePoint document library.

Troubleshooting

You can check the status of the email delivery from the IBM i server by running the command below and taking option 8 to view the log of the SMTP transaction.

WRKSMTPMSG OPTION(*ALL)

From the Power Automate screen you can review the run history of your flow, including details of any errors that occurred during processing.