Is the Message ID of an email supposed to change when moving that email from one Outlook folder to another Outlook folder with Flow or PowerApps?
I am trying to build a PowerApp to keep incoming emails organized in folders based on a workflow. The incoming emails must be reviewed, assigned, processed and then saved as originally received. This was previously performed manually via drag and drop by multiple users with rights to the email account. This prior approach eventually led to misfiled emails with little accountability for the users.
The proposed solution uses Flow to provide a Message ID of an incoming email when it arrives in a folder and then store that Message ID along with other email fields in a SharePoint list via Flow Create Item. My intent is to have each user review the emails via PowerApps, and then use the PowerApps Office365.Move([Message ID], folderPath) function to move an email from a first folder to a second folder to a third folder, etc... as the message proceeds through the workflow. The Office365.Move function works fine when moving an email from a first folder to a second folder, but it always fails when trying to move the same email from the second folder to a third folder when using the originally saved Message ID value. PowerApps will display a 502 error “Request failed. Try again later..” or a 404 error “The specific object was not found in the store…” when the attempt to move the email fails.
The issue is (I think) that whenever you move an email via Flow or PowerApps, the Message ID changes which breaks the reference between my SharePoint list item and the corresponding email.
The issue can be recreated with the following procedure to play a bit of Flow ping-pong:
- Create two folders in your Outlook inbox (e.g., TestFolder1, TestFolder2)
- Create a Sharepoint List with an “EmailID” field (single line text) and “Direction” field (single line text)
- Create a first Flow with three steps:
- Trigger on email arrive in TestFolder1
- Create Item in your SP list with *Title = [Subject] and EmailID=[Message ID] from the email in the trigger, and add a string in the Direction field to something like “Received in Folder 1”
- Move the Email based on the EmailID field to TestFolder2
- Create a second Flow with three steps:
- Trigger on email arrive in TestFolder2
- Create Item in your SP list with *Title = [Subject] and EmailID=[Message ID] from the email in the trigger, and add a string in the Direction field to something like “Received in Folder 2”
- Move the Email based on the EmailID field to TestFolder1
- Send yourself an email with “Test Email” in the subject line, and then drag that email into TestFolder1.
- Let the Flows run until you have a few data points to look at.
- Don’t forget to turn the Flows off!
When you do that, you can see that the EmailID columns are not exact. The majority of the characters match, but look at the end of the string. Here is what my data looked like when I ran the procedure above (I redacted the similar middle parts of the EmailIDs for efficiency of this post):
Title | EmailID | ReceiveTime | FolderDirection |
Test Email Ping-Pong | AAM ***** QMbqoAACKHjbgAAA= | 12/14/2018 5:10 | Received in Folder 1 |
Test Email Ping-Pong | AAM ***** QMbqoAAD4E8pNAAA= | 12/14/2018 5:10 | Received in Folder 2 |
Test Email Ping-Pong | AAM ***** QMbqoAAD4E842AAA= | 12/13/2018 21:10 | Received in Folder 1 |
Test Email Ping-Pong | AAM ***** QMbqoAAD4E8pOAAA= | 12/13/2018 21:10 | Received in Folder 2 |
Test Email Ping-Pong | AAM ***** QMbqoAAD4E843AAA= | 12/13/2018 21:10 | Received in Folder 1 |
Test Email Ping-Pong | AAM ***** QMbqoAAD4E8pPAAA= | 12/13/2018 21:10 | Received in Folder 2 |
Test Email Ping-Pong | AAM ***** QMbqoAAD4E844AAA= | 12/13/2018 21:10 | Received in Folder 1 |
Test Email Ping-Pong | AAM ***** QMbqoAAD4E8pQAAA= | 12/13/2018 21:10 | Received in Folder 2 |
Test Email Ping-Pong | AAM ***** QMbqoAAD4E845AAA= | 12/13/2018 21:10 | Received in Folder 1 |
If you try to use those EmailID values in a subsequent Flow or PowerApps function (e.g., Office365.GetEmail(EmailID).Subject) they will all fail except the last entry. That one usually works.
Assuming the above is correct, how can I determine the Message ID after a move operation? Do we need all of the characters in the Message ID string or can we use a Left(n) operation to use the characters that do not appear to be changed? Are there any other methods to use Flow and PowerApps to track an email regardless of its folder location?
Any assistance with this issue will be greatly appreciated.
Thanks!