Skip to main content

Notifications

Announcements

No record found.

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Bulk Delete email attachments.

    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!!!

  • Suggested answer
    ShahXu Profile Picture
    ShahXu 1,515 on at
    RE: Bulk Delete email attachments.

    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);

    }

  • Franglais Profile Picture
    Franglais on at
    RE: Bulk Delete email attachments.

    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?

  • Frank Lee Profile Picture
    Frank Lee 4,616 on at
    RE: Bulk Delete email attachments.

    Reference this doc:

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

  • RE: Bulk Delete email attachments.

    Hi Dan,

    Please refer to the link below for more information.

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

    Thank You !

  • Suggested answer
    Aaina Gupta Profile Picture
    Aaina Gupta on at
    RE: Bulk Delete email attachments.

    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.

  • Muhammad Adeel Javaid Profile Picture
    Muhammad Adeel Javaid 5,580 on at

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,820 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,514 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans