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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Delete email attachmen...
Power Apps
Unanswered

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

(3) ShareShare
ReportReport
Posted on by 237

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.

I have the same question (0)
  • Ethan_009 Profile Picture
    4,838 Moderator on at

    Hi @Mglat ,

     

    This looks like a nice approach. 

    I remember, there are 2 Tables (1 is on the Email Attachments grid which can be added/deleted and 2nd one is internal attachments which still holds the attachments even if its removed from Email grid. Now, these attachments which is internal entity that cannot be modified/deleted and even flow cannot perform the delete operation)

     

    Therefore, I used Action which used to call the Plugins and these were combined with a scheduled Flow or batch processing 100GB+ data.

    By using plugin, I was able to delete on attachments within internal entity and it was easier and faster.

     

    Thanks

     

  • wikap.dk Profile Picture
    13 on at

    Thanks Mglat!

    I managed to replicate the flow (using a "When record is selected" trigger). Hopefully this will free up the file attachment space we use 🙏.

  • urfandurrani Profile Picture
    5 on at

    Hi,

    This looks exactly like what I have been searching for, thanks!

    Since Iam new, can you elaborate on the step after the recurrance, for getting the dataverse base url?

    Is this a get row by ID action, on a specific table and row

    or is there a specific component that I need to use?

    Is the URL the environment URL (e.g. http://<environmentname>.crm11.dynamics.com )?

     

    Thanks in advance

    Urfan

     

  • wikap.dk Profile Picture
    13 on at

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

  • urfandurrani Profile Picture
    5 on at

    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

     

  • Acorr Profile Picture
    4 on at

    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 

  • Verified answer
    Marcel Lathouwers Profile Picture
    237 on at

    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 at

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

    Best regards

     

  • carterbarry88 Profile Picture
    64 on at

    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

  • Piny21 Profile Picture
    2 on at

    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! 

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 793 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 333 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard