Logic Apps - Move Email to Subfolder

%3CLINGO-SUB%20id%3D%22lingo-sub-148496%22%20slang%3D%22en-US%22%3ELogic%20Apps%20-%20Move%20Email%20to%20Subfolder%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-148496%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20fairly%20new%20to%20Logic%20Apps%20and%20I%20have%20an%20app%20that%20connects%20to%20a%20shared%20Exchange%20Online%20mailbox%20saves%20the%20attachments%20and%20then%20moves%20the%20email%20to%20a%20subfolder.%20I%20have%20everything%20working%20except%20moving%20the%20email%20to%20a%20subfolder.%26nbsp%3B%20I%20generate%20the%20path%20based%20on%20the%20date%20and%20I%20cannot%20for%20the%20life%20of%20me%20get%20it%20to%20work.%20I%20don't%20know%20if%20my%20path%20syntax%20is%20wrong%20or%20what.%3C%2FP%3E%0A%3CP%3EThis%20is%20the%20subfolder%20structure%3C%2FP%3E%0A%3CPRE%3E%3CCODE%3E-%20Inbox%0A%20-%202018%0A%20%20-%20Jan%0A%20%20-%20Feb%0A%20%20-%20Mar%0A%20%20-%20Etc%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EAnd%20I'm%20trying%20to%20generate%20the%20path%20based%20off%20the%20year%20and%20the%20month%20using%20the%20Expressions%20part%20of%20a%20field.%20I've%20got%20an%20expression%20that%20generates%20the%20path%20for%20me%3C%2FP%3E%0A%3CPRE%20class%3D%22lang-html%20prettyprint%20prettyprinted%22%3E%3CCODE%3E%3CSPAN%20class%3D%22pln%22%3Econcat('%2FInbox%2F'%2CformatDateTime(convertFromUtc(utcNow()%2C'Mountain%20Standard%20Time')%2C'yyyy')%2C'%2F'%2CformatDateTime(convertFromUtc(utcNow()%2C'Mountain%20Standard%20Time')%2C'MMM'))%3C%2FSPAN%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EWhen%20the%20logic%20app%20runs%20this%20generates%20the%20correct%20path%20string%20of%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3E%2FInbox%2F2018%2FJan%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B(I've%20also%20tried%20the%20following%20strings)%3C%2FSPAN%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%3EInbox%2F2018%2FJan%0AInbox%3A%2F2018%2FJan%3CBR%20%2F%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3Bbut%20when%20the%20Move%20Email%20action%20runs%20it%20always%20fails%20and%20gives%20an%20error%20that%20the%20folder%20does%20not%20exist.%3C%2FP%3E%0A%3CP%3ESo%20I%20either%20have%20the%20format%20wrong%2C%20I%20can't%20put%20the%20email%20in%20a%20subfolder%20or%20there's%20another%20way%20to%20do%20this.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20tried%20using%20the%20folder%20picker%20to%20pick%20one%20of%20the%20month%20subfolders%20and%20then%20peeked%20at%20the%20code%20and%20it%20uses%20some%20base64%20encoded%20string%20for%20the%20path.%20I've%20pasted%20below%20what%20the%20peeked%20code%20shows%3C%2FP%3E%0A%3CPRE%20class%3D%22lang-html%20prettyprint%20prettyprinted%22%3E%3CCODE%3E%3CSPAN%20class%3D%22pln%22%3E%7B%0A%20%20%20%20%22inputs%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22host%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22connection%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22%40parameters('%24connections')%5B'office365'%5D%5B'connectionId'%5D%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%22method%22%3A%20%22post%22%2C%0A%20%20%20%20%20%20%20%20%22path%22%3A%20%22%2FMail%2FMove%2F%40%7BencodeURIComponent(triggerBody()%3F%5B'Id'%5D)%7D%22%2C%0A%20%20%20%20%20%20%20%20%22queries%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22folderPath%22%3A%20%22Id%3A%3AAAMkADRmOTgyMDI1LThkODYtNDMwYy1iYThiLTIzODQwN2Y1OGMzYQAuAAAAAAA6K3dJssnITb8NwkAsBOo7AQBaJ9ZTcg-MSoOEUUjjUdOAAAAD0nvYAAA%3D%22%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%22authentication%22%3A%20%22%40parameters('%24authentication')%22%0A%20%20%20%20%7D%2C%0A%20%20%20%20%22metadata%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22Id%3A%3AAAMkADRmOTgyMDI1LThkODYtNDMwYy1iYThiLTIzODQwN2Y1OGMzYQAuAAAAAAA6K3dJssnITb8NwkAsBOo7AQBaJ9ZTcg-MSoOEUUjjUdOAAAAD0nvYAAA%3D%22%3A%20%22Jan%22%0A%20%20%20%20%7D%0A%7D%3C%2FSPAN%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EDoes%20anyone%20know%20how%20I%20would%20be%20able%20to%20move%20an%20email%20to%20a%20subfolder%20without%20using%20the%20folder%20picker%20(since%20the%20subfolder%20will%20change%20based%20on%20the%20month)%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-148496%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Contributor

I'm fairly new to Logic Apps and I have an app that connects to a shared Exchange Online mailbox saves the attachments and then moves the email to a subfolder. I have everything working except moving the email to a subfolder.  I generate the path based on the date and I cannot for the life of me get it to work. I don't know if my path syntax is wrong or what.

This is the subfolder structure

- Inbox
 - 2018
  - Jan
  - Feb
  - Mar
  - Etc

And I'm trying to generate the path based off the year and the month using the Expressions part of a field. I've got an expression that generates the path for me

concat('/Inbox/',formatDateTime(convertFromUtc(utcNow(),'Mountain Standard Time'),'yyyy'),'/',formatDateTime(convertFromUtc(utcNow(),'Mountain Standard Time'),'MMM'))

When the logic app runs this generates the correct path string of /Inbox/2018/Jan (I've also tried the following strings) 

Inbox/2018/Jan
Inbox:/2018/Jan

 but when the Move Email action runs it always fails and gives an error that the folder does not exist.

So I either have the format wrong, I can't put the email in a subfolder or there's another way to do this.

 

I tried using the folder picker to pick one of the month subfolders and then peeked at the code and it uses some base64 encoded string for the path. I've pasted below what the peeked code shows

{
    "inputs": {
        "host": {
            "connection": {
                "name": "@parameters('$connections')['office365']['connectionId']"
            }
        },
        "method": "post",
        "path": "/Mail/Move/@{encodeURIComponent(triggerBody()?['Id'])}",
        "queries": {
            "folderPath": "Id::AAMkADRmOTgyMDI1LThkODYtNDMwYy1iYThiLTIzODQwN2Y1OGMzYQAuAAAAAAA6K3dJssnITb8NwkAsBOo7AQBaJ9ZTcg-MSoOEUUjjUdOAAAAD0nvYAAA="
        },
        "authentication": "@parameters('$authentication')"
    },
    "metadata": {
        "Id::AAMkADRmOTgyMDI1LThkODYtNDMwYy1iYThiLTIzODQwN2Y1OGMzYQAuAAAAAAA6K3dJssnITb8NwkAsBOo7AQBaJ9ZTcg-MSoOEUUjjUdOAAAAD0nvYAAA=": "Jan"
    }
}

Does anyone know how I would be able to move an email to a subfolder without using the folder picker (since the subfolder will change based on the month)?

 

0 Replies