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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Bulk Delete email attachments.

(0) ShareShare
ReportReport
Posted on by

So I can use the advanced find to find thousands of emails with large file attachments, but there appears to be no way to bulk delete just those attachments without deleting the emails themselves.

Is this correct?

Anyone know of a way to set the default so that email attachments will not be stored in CRM?

*This post is locked for comments

I have the same question (0)
  • Muhammad Adeel Javaid Profile Picture
    5,580 on at
  • Suggested answer
    Aaina Gupta Profile Picture
    on at

    The emails would need to be reset to draft status first before you can delete the attachments and that can be done through a workflow or via the SDK. Setting the emails back to draft status would allow for a bulk deletion of email attachments.

  • AFTAB HUSSAIN Profile Picture
    on at

    Hi Dan,

    Please refer to the link below for more information.

    community.dynamics.com/.../216624.aspx

    Thank You !

  • Frank Lee Profile Picture
    4,617 on at

    Reference this doc:

    community.dynamics.com/.../deleting-email-attachments-in-dynamics-crm-2016

  • Franglais Profile Picture
    on at

    Looks like this no longer works sin D365 (well, at least in my instance it doesn't!)

    Anyone got an updated version of this tool?

  • Suggested answer
    ShahXu Profile Picture
    1,515 on at

    just use this code and you have no need to delete emails, it will delete all the attachments greater than mentioned size in below code

    IOrganizationService Service = GetCrmService();

    QueryExpression queryAtt = new QueryExpression("activitymimeattachment");

    queryAtt.ColumnSet = new ColumnSet(new string[] { "activityid", "attachmentid","filesize" });

    queryAtt.Criteria.AddCondition(new ConditionExpression("filesize", ConditionOperator.GreaterEqual, 100000));

    EntityCollection eatt = Service.RetrieveMultiple(queryAtt);

    foreach (Entity item in eatt.Entities)

    {

    Service.Delete(item.LogicalName,item.Id);

    }

  • Community Member Profile Picture
    on at

    Hey Shahzeb, what is the size of attachments that are larger then for this script? ConditionOperator.GreaterEqual, 100000));

    am i correct that this is greater then 100mb? Also will this script work in a crm 4.0 environment? Thanks!!!

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans