Learn How to Factory Reset your Gmail Account in easy steps

Advertisements

Hello, Guys welcome back to Learn How to Factory Reset your Gmail Account in easy steps. Your phone, iPad, and laptop all have a ‘hard reset’ option that returns your device to its factory default settings.

When you execute a factory reset, all programmes, files, and settings are erased, and there is no way to restore the deleted data. also Learn How to Download Speaker Notes in Google Slides

Nuke Gmail Account - Remove Everything

What is Gmail Factory Reset

Google Scripts can assist you if you ever need to “factory reset” an old Gmail account that you no longer use and start again with a clean slate. The script will do the following procedures to completely reset your Gmail account:

  1. Delete all Gmail labels
  2. Delete all Gmail filters
  3. Delete all Draft messages
  4. Delete all email messages in Gmail
  5. Delete all spam messages
  6. Permanently empty your Gmail trash folder
  7. Remove Out-of-Office message
  8. Disables POP and IMAP
  9. Remove all email signatures in Gmail
  10. Stops all email forwarding

Warning: Danger Ahead

Please keep in mind that a hard reset is an irreversible operation, and you will be unable to recover your Gmail data once the reset is completed.

Advertisements

You can find the Google Script on Github, or you may copy it into your Google account by clicking here. The script uses the official Gmail API to format your Gmail account.

Remove all Gmail Labels

const deleteGmailLabels = () => {
  GmailApp.getUserLabels().forEach((label) => {
    label.deleteLabel();
  });
};

Remove all Gmail Filters

const deleteGmailFilters = () => {
  const { filter: gmailFilters } = Gmail.Users.Settings.Filters.list('me');
  gmailFilters.forEach(({ id }) => {
    Gmail.Users.Settings.Filters.remove('me', id);
  });
};

Remove all Gmail Drafts

const deleteGmailDrafts = () => {
  GmailApp.getDrafts().forEach((draft) => {
    draft.deleteDraft();
  });
};

Reset Gmail Settings

Turning off vacation autoresponders, disabling IMAP and POP access, removing all email signatures, and disabling email forwarding are all options.

const resetGmailSettings = () => {
  const { Settings } = Gmail.Users;
  // Disable Out-of-office
  Settings.updateVacation({ enableAutoReply: false }, 'me');

  // Delete Gmail Signatures
  const { sendAs } = Settings.SendAs.list('me');
  sendAs.forEach(({ sendAsEmail }) => {
    Settings.SendAs.update({ signature: '' }, 'me', sendAsEmail);
  });

  // Disable IMAP
  Settings.updateImap({ enabled: false }, 'me');

  // Disable POP
  Settings.updatePop({ accessWindow: 'disabled' }, 'me');

  // Disable Auto Forwarding
  const { forwardingAddresses } = Settings.ForwardingAddresses.list('me');
  forwardingAddresses.forEach(({ forwardingEmail }) => {
    Settings.ForwardingAddresses.remove('me', forwardingEmail);
  });
};

Delete all Gmail Messages

All inbox messages, archived communications, and spam will be moved to the trash folder. Because Google Scripts can only run for 5 minutes in a single batch, we implemented a check to stop the script if it takes longer to complete.

const startTime = Date.now();
const isTimeLeft = () => {
  const ONE_SECOND = 1000;
  const MAX_EXECUTION_TIME = ONE_SECOND * 60 * 5;
  return MAX_EXECUTION_TIME > Date.now() - startTime;
};

/**
 * Move all Gmail threads to trash folder
 */
const deleteGmailThreads = () => {
  let threads = [];
  do {
    threads = GmailApp.search('in:all', 0, 100);
    if (threads.length > 0) {
      GmailApp.moveThreadsToTrash(threads);
      Utilities.sleep(1000);
    }
  } while (threads.length && isTimeLeft());
};

/**
 * Move all Spam email messages to the Gmail Recyle bin
 */
const deleteSpamEmails = () => {
  let threads = [];
  do {
    threads = GmailApp.getSpamThreads(0, 10);
    if (threads.length > 0) {
      GmailApp.moveThreadsToTrash(threads);
      Utilities.sleep(1000);
    }
  } while (threads.length && isTimeLeft());
};

Permanently Empty the Trash Folder

/**
 * Permanetly empty the Trash folder
 */
const emptyGmailTrash = () => {
  let threads = [];
  do {
    threads = GmailApp.getTrashThreads(0, 100);
    threads.forEach((thread) => {
      Gmail.Users.Threads.remove('me', thread.getId());
    });
  } while (threads.length && isTimeLeft());
};

Also: Learn How to Use Google Sheets with D3.js and Google Visualization

Advertisements

Leave a Comment