Archiving and Clearing Inbox Using KingswaySoft

28 March 2024
KingswaySoft Team

When working on integrations, it's common to receive notifications via emails from the process. These emails may include execution statuses, pipeline monitoring messages, execution failure notifications, or other communications. However, keeping these indefinitely in the inbox might not be desirable, as they can accumulate in both number and size over time. Therefore, moving selected emails to another folder to clear up space in the main inbox is an important step that may need to be done regularly. This would require a tool or process that can move/copy the emails (or archive them to another folder), validate the move/copy completion, and then delete them from the inbox, all of which can be easily accomplished using KingswaySoft.

In this blog post, we will demonstrate an integration flow using KingswaySoft components, enabling you to copy any processed emails to a subfolder and remove them from the original inbox. Also, for this example, we will use Exchange Web Services (EWS) to connect to Outlook mailboxes. Below are the components that we will use:

Process Emails - Read and Copy the Required Items

The email data flow process will perform the task of copying the emails from your main inbox to another folder, based on any filter that you provide. The general data flow will look as follows:

ProcessEmailDataFlow.png

First, we will use the Email Source Component to read the emails and to define the filter. With the Email Source Component, we will be reading from the Inbox Folder. We will use the filter to see if the Subject contains a term called "Notification". If yes, then only those will be read.

EmailSourceRead.png

Please be aware that there is a "Post Retrieve Action" in the Email Source component that can be used to Soft Delete or Hard Delete the email after reading it. You could simplify the design by using that. However, it's important to note that this action does not verify whether the emails were actually moved to another folder, as it occurs immediately after the Source component reads them, regardless of whether the email was written to the Destination or not. Mind that failure at the Destination could lead to data loss and premature deletion of the emails read by the Source component.

Continuing the data flow, in the Premium Derived Column component, we will create a new column with the name of the folder to which we want to move our messages. In our case, we have created a folder called "Processed Folder" in our mailbox and will be using that.

ProcessEmailDataFlow.png

In the Email Destination component, we will use the action Copy Message to copy the email to the Processed Folder.

CopyEmail.png

The Column mappings in the "columns" page will have the SourceFolderPath and the UniqueID from the Email Source component. The TargetFolderPath will then be the folder path that we have added in the Premium Derived Column Component. Map these as shown below:

CopyEmailFields.png

With this first data flow complete, the email should be successfully copied over to the Target Folder. In the next data flow, we will be deleting the message we just copied from the original folder.

Delete Email - The Process of Validation and Deletion from Inbox

In this data flow, we will delete the message we just copied from the original folder. However a problem arises if one of the emails does not get copied over for any reason, such as network/memory/server-side issues; in such cases, we will end up deleting the email without it being copied over. This is why we added a Premium Lookup Component that allows us to validate if the email messages have been successfully copied over to the new folder.

DeleteProcessedEmail.png

In the Delete Email data flow, we will have two Email Source Components. The firstEmail Source component will read from the Processed Folder, while the second Email Source Component will read from the original messages' location, namely, the Inbox.

EmailSourceProcessed.png

  EmailSourceValidate.png

The Premium Lookup will be used to validate that the email has been successfully copied over to the Processed Folder. We will be performing a lookup on the MessageID. If there is an exact match between the Inbox and the Processed Folder, then it means that the message was successfully copied over.

PremiumLookup.png

PremiumLookupColumns.png

You can output the UniqueId and the FolderPath of the message. The output of the Matched Rows will be input into the Email Destination component. In the Destination component, you will perform the Delete action on the message. You can either choose a Soft Delete or a Hard Delete.

EmailDestinationDelete.png

A soft-deleted message is moved to a user's Recoverable Items folder and retained until the deleted item retention period expires. On the other hand, hard-deleted messages are marked for permanent removal from the mailbox and will be deleted permanently the next time the mailbox is processed by the Managed Folder Assistant. Choosing a Soft or Hard Delete will be up to you, based on your business requirements.  The Email Destination Component will then have the columns mapped accordingly.

EmailDestinationColumns.png

The overall control flow design would look as below

Conclusion

By using the above strategy, you would be performing thorough validation of copied/moved emails before their deletion, ensuring that no data loss occurs during the process. This is an important aspect of any archival mechanism. 

We hope this has helped!

 About 

Archive

November 2024 3 October 2024 1 September 2024 1 August 2024 2 July 2024 1 June 2024 1 May 2024 1 April 2024 2 March 2024 2 February 2024 2 January 2024 2 December 2023 1 November 2023 1 October 2023 2 August 2023 1 July 2023 2 June 2023 1 May 2023 2 April 2023 1 March 2023 1 February 2023 1 January 2023 2 December 2022 1 November 2022 2 October 2022 2 September 2022 2 August 2022 2 July 2022 3 June 2022 2 May 2022 2 April 2022 3 March 2022 2 February 2022 1 January 2022 2 December 2021 1 October 2021 1 September 2021 2 August 2021 2 July 2021 2 June 2021 1 May 2021 1 April 2021 2 March 2021 2 February 2021 2 January 2021 2 December 2020 2 November 2020 4 October 2020 1 September 2020 3 August 2020 2 July 2020 1 June 2020 2 May 2020 1 April 2020 1 March 2020 1 February 2020 1 January 2020 1 December 2019 1 November 2019 1 October 2019 1 May 2019 1 February 2019 1 December 2018 2 November 2018 1 October 2018 4 September 2018 1 August 2018 1 July 2018 1 June 2018 3 April 2018 3 March 2018 3 February 2018 3 January 2018 2 December 2017 1 April 2017 1 March 2017 7 December 2016 1 November 2016 2 October 2016 1 September 2016 4 August 2016 1 June 2016 1 May 2016 3 April 2016 1 August 2015 1 April 2015 10 August 2014 1 July 2014 1 June 2014 2 May 2014 2 February 2014 1 January 2014 2 October 2013 1 September 2013 2 August 2013 2 June 2013 5 May 2013 2 March 2013 1 February 2013 1 January 2013 1 December 2012 2 November 2012 2 September 2012 2 July 2012 1 May 2012 3 April 2012 2 March 2012 2 January 2012 1

Tags