web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : bVyydb9FW6hA3BmLv4gID8
Power Apps - Microsoft Dataverse
Answered

Delete email attachments from Dataverse (Dynamics 365 Sales/Service)

Like (3) ShareShare
ReportReport
Posted on 23 Jan 2024 17:56:54 by 236

After scouring the web for a solution to remove email attachments in bulk without affecting the original messages, I finally discovered a way to achieve this with the help of power automate. In this post, I will share my method with you.

The attachment tables in Dataverse (there are more than one) are not easy to delete from. The standard Dataverse connector cannot handle this task.

The overall flow looks like this

2024-01-23_18-12-53.png

 

The dataverse action is just a little trick to get the URL to the environment where the flow is running. This way the rest of the flow will use dynamic references and no hardcoded URLs

Then I determine a cutoff date. From all emails older than this date the attachment should be removed.

2024-01-23_18-36-45.png

Then two HTTP actions follow. There was a name change recently and currently called 'HTTP with Microsoft Entra ID (preauthorized)'

I like to use this connector for fancy stuf that you can do with the Dataverse webAPI, but not with the dataverse connector.

The first HTTP call gathers the attachment. Of course, you can create your own filters here.

2024-01-23_18-07-51.png

 

The second HTTP loops through all the found attachments and executes a delete action.

2024-01-23_18-10-50.png

 

https://@{uriHost( outputs('Get_Dataverse_BaseURL')?['body/@odata.context'] )}/api/data/v9.2/activitymimeattachments(@{items('For_each_attachment')['activitymimeattachmentid']})

Remember to set the concurrency in the Apply To Each settings.

Categories:
  • 365-Assist Profile Picture
    2,316 Moderator on 27 Jul 2025 at 05:06:21
    Delete email attachments from Dataverse (Dynamics 365 Sales/Service)
    Thanks for this post. 
     
    If people are interested in doing this using the Dataverse connectors (Not HTTP Requests) I made a video showing how -> https://youtu.be/TN_eU5OeRIc
  • carterbarry88 Profile Picture
    64 on 13 Jul 2024 at 10:43:13
    Re: Delete email attachments from Dataverse (Dynamics 365 Sales/Service)

    Hi, it would be helpful if you provided a more detailed error message but I can see you're trying to delete the wrong type of attachment record. As I mentioned in my previous comment there are 2 tables named attachment in the drop down. You must make sure to delete the activity mime attachment record. 

  • Beeless_Burt Profile Picture
    2 on 12 Jul 2024 at 14:45:00
    Re: Delete email attachments from Dataverse (Dynamics 365 Sales/Service)

    Could you perhaps provide some more information about the error?

    I'm also looking into a solution for this.

  • Piny21 Profile Picture
    2 on 11 Jun 2024 at 22:39:27
    Re: Delete email attachments from Dataverse (Dynamics 365 Sales/Service)

    Hi @carterbarry88 ,

     

    Can you please explain in the details? or some more pic pls?

     

    I would like to delete the attachment , the problem is i'm getting error while "Delete the record or update the record".

     

    I got the rows, 

     

    Piny21_0-1718145180021.png

    Piny21_2-1718145310414.png

     

    Piny21_1-1718145239471.png

    After the execution ,

     

    Piny21_3-1718145423599.png

     

    Piny21_4-1718145445112.png

     

    I really appreciate if you can help.

     

    Thank you! 

     

  • carterbarry88 Profile Picture
    64 on 28 May 2024 at 09:40:25
    Re: Delete email attachments from Dataverse (Dynamics 365 Sales/Service)

    Hi there,

     

    Thought I would add my two cents here. Potentially there has been an improvement in the connector since this was posted, but I was able to delete a record from the "Activity Mime Attachment" table using the Dataverse Connector.

     

    It is possible to select the "Attachments" entity in the drop down list. Note there are 2 entities named "Attachments". In my environment, it was the first one. To make sure of your selection, "peek code" and ensure that the action is pointed at the "activitymimeattachments" entity. I was able to point the following Dataverse actions against the table:
    - Get row

    - Delete row

    - List rows

     

    carterbarry88_0-1716888924152.png

    carterbarry88_1-1716889038732.png

    After running the action, the attachment was removed from the email record

    carterbarry88_2-1716889205778.png

    Hope this helps someone

  • Acorr Profile Picture
    4 on 30 Apr 2024 at 09:28:53
    Re: Delete email attachments from Dataverse (Dynamics 365 Sales/Service)

    Thank you so much for your help here, its very much appreciated. 

    Best regards

     

  • Verified answer
    Marcel Lathouwers Profile Picture
    236 on 30 Apr 2024 at 09:14:59
    Re: Delete email attachments from Dataverse (Dynamics 365 Sales/Service)

    Hi @mcgeeardee 

    The 'Get Base URL' is a Dataverse List rows action. Just point it to a table that will have records in it, e.g. the accounts table. 

    Get just 1 record to reduce the data. the output of this step is then used to create the URL path in the expression 

    uriHost( outputs('Get_Dataverse_BaseURL')?['body/@odata.context'] )

     

    Mglat_0-1714468429645.png

     

  • Acorr Profile Picture
    4 on 18 Apr 2024 at 12:58:49
    Re: Delete email attachments from Dataverse (Dynamics 365 Sales/Service)

    Hello such a useful tool and I have looked for something like this for a very long time.
    I need help with the Get Base URL Step. Would you please detail how you created this?

    Thank you again 

  • urfandurrani Profile Picture
    5 on 03 Apr 2024 at 13:12:24
    Re: Delete email attachments from Dataverse (Dynamics 365 Sales/Service)

    Great, was thinking that but the icon in the image above confused me (its a dataverse icon isnt it?)

    So the variable value is something like: e.g. http://<environmentname>.crm11.dynamics.com 

    Urfan

     

  • wikap.dk Profile Picture
    11 on 03 Apr 2024 at 13:05:26
    Re: Delete email attachments from Dataverse (Dynamics 365 Sales/Service)

    I just initiated an variable where I hard-coded the environment URL (making it flexible in the steps afterwards)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2

Featured topics

Loading complete