Clear All Archived Emails

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stef204
    Junior Member
    • Jun 2024
    • 23

    Clear All Archived Emails

    I decided to give espocrm a try with a company email account (configured as personal email account) and fetched a few weeks of emails. I then decided not to continue using email with espocrm (just use espocrm without the email feature), so I sent to trash all emails, then found out was better to "remove" them, which I did.

    However all emails still show up in the "activity" and "history" of user "Admin" which means they are still there archived somewhere, and able to be "restored". I want to be able to purge all of these emails from espocrm. How do I do this?

    Also, and related, I cannot see a way of clearing the stream of emails for the user, there is an individual entry for each email received in the stream. How can I completely clear each stream entry for these emails for user Admin in one shot (all at once, not individually, there are too many of them)?

    I am using 8.2.5 with docker.
    Last edited by stef204; 06-20-2024, 01:33 AM.
  • dimyy
    Active Community Member
    • Jun 2018
    • 569

    #2
    You can delete all comments in the stream via the DB by deleting all "note" entries whose "related_type" is "Email"

    Comment

    • dimyy
      Active Community Member
      • Jun 2018
      • 569

      #3
      Or you can do it throw sandbox, using script like this:

      Code:
      $notedForDelete = record\findMany('Note', 100, 'createdAt', 'desc', 'relatedType', 'Email');
      output\printLine($notedForDelete);
      
      $i = 0;
      $count = array\length($notedForDelete);
      
      while ($i < $count) {
          
          record\delete('Note', array\at($notedForDelete, $i) );
          
          $i = $i+1;
      }

      Comment

      • stef204
        Junior Member
        • Jun 2024
        • 23

        #4
        Originally posted by dimyy
        You can delete all comments in the stream via the DB by deleting all "note" entries whose "related_type" is "Email"
        Can you explain in more detail how to do that? Does this mean having to connect to the mysql db inside the docker container via cli?

        Comment

        • stef204
          Junior Member
          • Jun 2024
          • 23

          #5
          And how do I also purge all archived emails do that they are completely removed from the database and are not able to be restored? Right now, all emails are still there even after using "Sent to Trash" + "Remove" -- the emails are still stored somewhere in the database. How do I purge them?

          Note: if I connect to the mysql docker container using dbvis, for example (GUI to manage databases) I can see hundreds of emails in the table "email" all with the status "deleted: true".

          So how do these get removed completely from the database in a clean way, so that they no longer show up in the espocrm web interface and cannot be restored?
          Last edited by stef204; 06-20-2024, 12:42 PM.

          Comment

          • stef204
            Junior Member
            • Jun 2024
            • 23

            #6
            Originally posted by dimyy
            Or you can do it throw sandbox, using script like this:

            Code:
            $notedForDelete = record\findMany('Note', 100, 'createdAt', 'desc', 'relatedType', 'Email');
            output\printLine($notedForDelete);
            
            $i = 0;
            $count = array\length($notedForDelete);
            
            while ($i < $count) {
            
            record\delete('Note', array\at($notedForDelete, $i) );
            
            $i = $i+1;
            }
            This seemed to have worked. Those entries seem to have disappeared. Thanks.

            Now I need to purge the deleted emails from the DB as explained above.

            Comment

            • stef204
              Junior Member
              • Jun 2024
              • 23

              #7
              So I basically used DBVIS to log into the mysql database and then used the following statement:

              Code:
              DELETE FROM email
              WHERE deleted = true;
              It worked, I don't see any negative side effects so far.

              Let me know if this was not recommended or if I can expect side effects from doing it that way.

              Thanks.

              Comment

              Working...