Deleting emails and their attachments

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mark
    Senior Member
    • Dec 2019
    • 143

    Deleting emails and their attachments

    Hi,

    We are trying to delete some old emails and their attachments, since they are taking a lot of space. But we encountered a few problems:
    1. We want to keep emails that were sent or received by certain email accounts.
    2. Deleting emails in Espocrm itself does not delete them from the database instantly and as I understand if you set 'Clean up deleted records' to true, it only deletes them after 90 days. Is there anyway to change this setting, so it deletes the records faster or instantly from the database also?
    3. Also if we delete the emails and clean the deleted records, will it also remove the associated attachments that are stored in the file system?
  • emillod
    Active Community Member
    • Apr 2017
    • 1405

    #2
    Hello Mark
    You can remove emails directly from database. You can also create custom cleanup script which will don't wait X days.
    Yes, if attachment is not related to anything, then cleanup should also remove attachments.

    You can also create your own job which will take X mails per minute and remove them only if they meet conditions. Then you can use this command to remove them from database immediately - https://docs.espocrm.com/development...delete-from-db

    Comment

    • alter
      Member
      • Apr 2018
      • 57

      #3
      Hi, simply create a scheduled job with a condition you want emails to be deleted and run every 24 hours for example. I would not go under 24 hours (12 hours, 1 hour), because that is extremely unnecessary. Best logic I would recommend - "Every 24 hours, delete all emails, that are {condition}"

      Comment

      • stef204
        Junior Member
        • Jun 2024
        • 23

        #4
        Originally posted by alter
        Hi, simply create a scheduled job with a condition you want emails to be deleted and run every 24 hours for example. I would not go under 24 hours (12 hours, 1 hour), because that is extremely unnecessary. Best logic I would recommend - "Every 24 hours, delete all emails, that are {condition}"
        I realize this is an old thread but can you please explain how to do this?

        Comment

        • rabii
          Active Community Member
          • Jun 2016
          • 1250

          #5
          You can create a custom job and run it on a schedule of your choice. see documentation below

          Rabii
          Web Dev

          Comment

          Working...