Email Deletion

151 views
Skip to first unread message

Rajagopal Suresh

unread,
Aug 23, 2021, 2:34:48 AM8/23/21
to GAM for Google Workspace
Hi,


I am using the below command to delete emails from the inbox. Could you please guide me how can i delete emails prior to 2019 years emails from inbox or labels and certain date limit.

Command
gam user mye...@test.com delete messages query "in:inbox" max_to_delete 900000 doit

Ross Scroggs

unread,
Aug 23, 2021, 10:42:37 AM8/23/21
to google-ap...@googlegroups.com
Rajagopal,

It describes the query options.

Ross

--
You received this message because you are subscribed to the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/9089e338-2a5a-4893-8a2e-fb8fdaab9551n%40googlegroups.com.


--

Rajagopal Suresh

unread,
Mar 4, 2022, 6:52:38 AMMar 4
to GAM for Google Workspace
Hi,


Can you please give me gam command to delete emails between the date range from all the labels in GSuite accounts.

Ross Scroggs

unread,
Mar 4, 2022, 11:12:14 AMMar 4
to google-ap...@googlegroups.com

Rajagopal Suresh

unread,
Mar 7, 2022, 5:39:57 AMMar 7
to GAM for Google Workspace
Hi Ross,

The below GAM command is not deleting the emails after 31st Jan'22 emails in entire labels.

Please suggest and let me know the exact syntax to delete emails in one shot from all the labels in the email account.


gam user it-b...@test.com delete messages query after:2022/1/31

Ross Scroggs

unread,
Mar 7, 2022, 10:09:38 AMMar 7
to google-ap...@googlegroups.com
gam <UserTypeEntity> delete messages query <QueryGmail> [doit] [max_to_delete|max_to_process <Number>]


The command should be:
gam user it-b...@test.com delete messages query after:2022/01/31 max_to_delete 10000 doit

You have to specify the maximum number of messages to delete and specify doit to conform deletion.

Rajagopal Suresh

unread,
Mar 7, 2022, 10:54:03 PMMar 7
to GAM for Google Workspace
Thanks. It is working.

Rajagopal Suresh

unread,
Jul 1, 2022, 1:06:06 AMJul 1
to GAM for Google Workspace
Hi Ross,

I am using this query gam user suresh.r...@test.com delete messages query "label:gsuit-alerts before:2022/01/31" max_to_delete 9000000 doit

Please guide me to exclude to delete emails that are directly marked to suresh.r...@test.com using the above command.

Thanks.

Ross Scroggs

unread,
Jul 1, 2022, 8:41:33 AMJul 1
to google-ap...@googlegroups.com
See: https://support.google.com/mail/answer/7190

gam user suresh.r...@test.com delete messages query "label:gsuit-alerts before:2022/01/31 to:suresh.rajagopal@test.com" max_to_delete 9000000 doit

Ross

Rajagopal Suresh

unread,
Jul 4, 2022, 8:21:25 AMJul 4
to GAM for Google Workspace
Hi Ross,

Thanks for your reply.

This query is deleting emails marked directly to suresh.r...@test.com. Actually, I do not want to delete emails directly marked to suresh.r...@test.com from that particular label and delete the remaining emails. Please help.

Ross Scroggs

unread,
Jul 5, 2022, 11:20:41 AMJul 5
to google-ap...@googlegroups.com
This was your request: Please guide me to exclude to delete emails that are directly marked to suresh.r...@test.com using the above command.

Now you say: This query is deleting emails marked directly to suresh.r...@test.com. Actually, I do not want to delete emails directly marked to suresh.r...@test.com from that particular label and delete the remaining emails. Please help.


Contact me via Meet/Zoom so I can determine what you actually want.

Ross



--

Rajagopal Suresh

unread,
Jul 22, 2022, 2:36:03 AMJul 22
to GAM for Google Workspace
Hi Ross,

sorry for the delayed response. I tried with the below query to solve my requirements.
gam user suresh.r...@test.com delete messages query "label:gsuit-alerts before:2022/07/01 !to:suresh.rajagopal@test" max_to_delete 9000000 doit

I need one more help to find out the size and email counts of each label on my account. 
to understand the storage where it is taking more space so please let me know the query if possible.

Ross Scroggs

unread,
Jul 22, 2022, 11:38:37 AMJul 22
to google-ap...@googlegroups.com
Rajagopal,

Try this:

gam config csv_output_header_filter "User,Labels,SizeEstimate" redirect csv ./Messages.csv user us...@domain.com print messages showsize showlabels headers ""


You will get a row per message with its labels and size. You can process this data with a script to generate totals.


Ross




--

Ross Scroggs

unread,
Jul 22, 2022, 11:41:56 AMJul 22
to google-ap...@googlegroups.com
Rajagopal,

This will give you label count information but no size information.

gam redirect csv ./LabelCounts.csv user us...@domain.com print labels showcounts


Ross

--

Ross Scroggs

unread,
Jul 22, 2022, 11:53:18 AMJul 22
to google-ap...@googlegroups.com
Rajagopol,


Ross
--

Rajagopal Suresh

unread,
Jul 26, 2022, 2:02:47 AMJul 26
to GAM for Google Workspace
Hi Ross,

Thank you so much for your help.

Rajagopal Suresh

unread,
Jul 26, 2022, 2:24:30 AMJul 26
to GAM for Google Workspace
Hi Ross,

I am getting this error config is not a valid argument for "gam"  while trying gam config csv_output_header_filter "User,Labels,SizeEstimate" redirect csv ./Messages.csv user us...@domain.com print messages showsize showlabels headers ""

Also, getting similar error redirect is not a valid argument for "gam"  for this query gam redirect csv ./LabelCounts.csv user us...@domain.com print labels showcounts

Ross Scroggs

unread,
Jul 26, 2022, 9:35:40 AMJul 26
to google-ap...@googlegroups.com

Rajagopal Suresh

unread,
4:00 AM (8 hours ago) 4:00 AM
to GAM for Google Workspace
Hi,
Thanks.

I have installed AdvancedGAM and tried the below query but getting this ERROR: [Errno 11001] getaddrinfo failed (after got 398784 messages)

gam config csv_output_header_filter "User,Labels,SizeEstimate" redirect csv ./Messages.csv suresh@domain.com print messages showsize showlabels headers ""

Please suggest to me if you have any solution.

Reply all
Reply to author
Forward
0 new messages