All Categories

Introduction

In this article, I will explain the complete step by step process of how to Factory Reset your Gmail Account in a simple and easy way.

We will get a Hard Reset option in your phone or iPad or your laptop that resets your device to the default factory settings. Once you have done a factory reset for any device, it deletes all the apps, files, and settings and there’s no way to recover the deleted data.

What is Gmail Factory Reset

If you want to do Factory Reset for any of your old Gmail accounts that you no longer use, then Google Scripts will help you more. However, this summary will make a list of responsibilities to effectively reset your Gmail account.

Warning: 

In addition, before you continue, please understand that a hard reset is an unchangeable process and you will not be able to get your Gmail data once the reset is completed.

The Google Script is available for free on Github. You can also just copy the below script into your Google account. The script will use the standard official Gmail API to Delete/Format your Gmail account data.

Click here to run the below code 

Remove all Gmail Labels

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

To 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

Moreover, It will turn off holiday autoresponders, disable IMAP and POP access, eliminates all email signatures, and disables email forwarding.

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

However, this code will remove all inbox messages, archived messages, and spam to the trash folder. Google Scripts can run for 5 minutes in one group so we added a check to stop the script if it is taking 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());
};

Conclusion

This is all about how to Factory Reset your Gmail Account in a simple and easy way.If you know about any other process please comment below.

Thanks for your support we will provide more tricks & tips for you. If you like our tricks, share these with your friends and join my Telegram Channel for more new tricks & tips.


Shopping cart
Sign in

No account yet?

Facebook Instagram YouTube WhatsApp WhatsApp Telegram
Sidebar
error: Content is protected by Narendra
How can i help you ?