Corrupted file being uploaded from shared mailbox to Sharepoint

As the title suggests, I am in the process of creating a flow that carries out the following three tasks:

  1. Retrieve email with attachment from a shared mailbox

  2. Renames the attachment as per this format - MM XXX MMM yyyy (e.g 02 XXX Feb 2023)

  3. Upload the file to a specific sharepoint folder

For point no.2, I am using ‘Compose’ and then inputting the following custom expression:

formatDateTime(utcNow(), ‘MM sample - MMM yyyy’)

Once I have done that, for uploading the file on sharepoint (task 3), I use the ‘create file in sharepoint’ flow and fill the site and folder details. For attachment name, I then select the Output from task 2 and for attachment content i select the attachment content from task 1.

When i test the flow, the attachment gets uploaded to sharepoint with the correct new name but the file is corrupted.

I think that the problem is with task 2 because if i dont try to rename the file and eliminate that step, the file gets uploaded without getting renamed but is NOT corrupted. Can anyone please help me with this?