Create new label with emails/conversations older than

85 views
Skip to first unread message

Peer Elmelund

unread,
Oct 10, 2022, 6:18:30 AM10/10/22
to GAM for Google Workspace
Hi,

I am about to make a new label for for all users; that holds all emails older than a certain date.

I know how to use:

gam print users query isSuspended=False | gam csv - gam user ~primaryEmail label "NewLabel"

-next step is to apply this label to all emails older than eg. 1970-01-01 - is that possible in one single command?

Ross Scroggs

unread,
Oct 10, 2022, 11:57:54 AM10/10/22
to google-ap...@googlegroups.com
This is an Advanced GAM solution.

Gmail query documentation

Advanced GAM documentation
https://github.com/taers232c/GAMADV-XTD3/wiki/Users-Gmail-Labels#add-a-label                                                                                                                                                                            
https://github.com/taers232c/GAMADV-XTD3/wiki/Users-Gmail-Messages-Threads#manage-messagesthreads                                                                                                                                                       

Get list of non-suspended users
gam redirect csv ./Users.csv all users print users fields primaryemail

Add label to each user
gam redirect stdout - multiprocess csv Users.csv gam user "~primaryEmail" label "OldMessages"

Label messages old than a year; adjust as desired; see Gmail query documentation
To test, omit doit
gam redirect stdout - multiprocess csv Users.csv gam user "~primaryEmail" modify messages query "older_than:1y" addlabel "OldMessages" maxtomodify 0 doit

Ross

----
Ross Scroggs



--
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/e367a17d-a953-4d06-8bbe-9c3c820d54c5n%40googlegroups.com.

Peer Elmelund

unread,
Oct 11, 2022, 5:29:05 AM10/11/22
to GAM for Google Workspace
Hi Ross,

Thank you very much, what luxus to get the complete taylored command! :)

When GAM counts messages, it counts eg. 100.000 messages in my new folder, but at gmail.com it counts only around 10.000. Is it becuase GAM counts every single email, and gmail.com counts the threads?

Peer Elmelund

unread,
Oct 11, 2022, 5:56:30 AM10/11/22
to GAM for Google Workspace
To answer my self, yes gmail.com counts threads, gam counts all messages. Verified by: gam user 'email' print labels showcounts todrive - cool command btw.

Ross Scroggs

unread,
Oct 11, 2022, 9:53:00 AM10/11/22
to google-ap...@googlegroups.com
This command: gam user 'email' print labels showcounts todrive
gives you both message counts and thread counts

Ross
----
Ross Scroggs


Peer Elmelund - Opus Group

unread,
Oct 11, 2022, 10:13:11 AM10/11/22
to google-ap...@googlegroups.com
Yes, its a nifty command!

You received this message because you are subscribed to a topic in the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-manager/W8-ZG_V4pjY/unsubscribe.
To unsubscribe from this group and all its topics, 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/F8DAAA00-C9D4-4E36-AAE1-323C744382D1%40gmail.com.
--
Peer Elmelund – Digital Infrastructure Specialist

Phone: +45 3212 9062 | E-mail: p...@opusgroup.dk
Opus Group is a part of Athenas aps - Flakhaven 1, 1. Sal, 5000 Odense C
Reply all
Reply to author
Forward
0 new messages