Gmail Attachment Sort Bot

This bot will download attachments from Gmail and then move files to corresponding folder that have file extension as folder name.

Features:

⦁ Downloads Attachments from Mail effectively.

⦁ Creates folder and copy files to the corresponding folders, based on the extension,

⦁ Easy to find and identify file extensions.

⦁ Bot will move the files to the respective extension folders

⦁ Reduce human effort and time.

Bot Work Flow

Working:

  • Get IMAP Mail activity is used to retrieve email messages using the IMAP server. The email account used to get the message. Mail folder and the password of the email account can be given at the email configuration section. The output of this activity is a list that stores variables of type Mime message.

  • Next, we can use For Each activity. It takes an item from the input Message list, and uses it to execute the rest of the steps until it encounters the loop end. When the execution reaches the loop end it will check if all items in the collection are processed, the next activity is executed.

  • Save attachment activity saves the attachment for each mail messages to the user specified folder. If the user specified folder does not exist, it is created. In the input section, the list of Mime Message objects whose attachments are to be saved and the output file path of the folder where the attachments are to be saved can be given. We can create a folder variable and assign the folder path in to the variable.

  • End loop activity will mark the end of the loop, if there are no more items to process in the collection.

  • List files activity lists all the files in the user specified folder location. Here we have to specify the folder where we have saved the mail attachments in the input location field. The output of this activity is a list which stores the list of files objects in the folder.

  • Now, we have to use For Each activity again to iterate through the list of files.

  • Now we have to move files with same extension to one folder which has the file extension as folder name, inside the root folder. By using the expressions “FolderPath.Value” and “Item2.Extension”, the user will get the folder path value and file extension respectively. Here the Folder path is the folder variable where we have saved all the files and the Item2 is the output of For Each activity. To get the destination file path, we have to use Join Text activity. This activity will join the value of folder path and file extension with “\” as middle string which gives the destination folder path.

  • Now we can move each file to the respective folders by using Move file activity. Here, the output of Join text activity is the destination folder and “Item2.Value” is the source folder. In order to get the name of source file path we can add “.value” to the output of For Each activity. I e., “Item2.Value”

  • Finally, we can end the second loop by using End loop activity

Output

Last updated