Can GAM show me which delegates sent messages in a given date range?

323 views
Skip to first unread message

Lior W.

unread,
Jun 11, 2021, 4:35:26 PM6/11/21
to GAM for Google Workspace
I have a shared mail box with various delegates sending mail from it.
I'd like to know during let's say 2 days who sent how many messages.
Can I get a CSV looking like:

Date range: 2021--06-01 - 2021-06-02
Delegate - Count of message sent from sharedATgmail.com
delegate1ATgmail.com - 20
delegate2ATgmail.com - 12
delegate3ATgmail.com - 3

?

If it helps, delegated sent messages have two headers:
  1. Sender: address of delegate
  2. X-Google-Sender-Delegation:  address of delegate
For example:
delegate headers.png

Ross Scroggs

unread,
Jun 16, 2021, 12:38:24 PM6/16/21
to google-ap...@googlegroups.com
Lior,

This will require Advanced GAM (https://github.com/taers232c/GAMADV-XTD3/)

Make a CSV file (Delegates.csv) with a column delegate.
delegate

gam redirect csv ./SentByDelegates.csv multiprocess csv Delegates.csv gam user "~delegate" print messages query "in:sent after:2021/06/01 before:2021/06/02 from:sha...@domain.com" countsonly


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/b0568893-e45d-4f70-acf5-94fc61e9b834n%40googlegroups.com.


--

Lior W.

unread,
Jun 18, 2021, 2:42:56 AM6/18/21
to GAM for Google Workspace
Thanks! Does it require Advanced GAM because of the delegation or because of the grouping?

If it's about the grouping, how about a way to just output every single message that was ever sent from SharedATgmail.com, but just mention who was the delegate? That is:
Date - Delegate (if needed, could use getHeader)
Or
Date - Delegate - Subject

Ross Scroggs

unread,
Jun 18, 2021, 8:45:33 AM6/18/21
to google-ap...@googlegroups.com
Lior,

It requires Advanced GAM because Standard GAM has no print messages command.

Ross

Lior W.

unread,
Jun 18, 2021, 12:47:45 PM6/18/21
to GAM for Google Workspace
I see, wish it did. :-)
Do you know the command to Advanced GAM for my last question?

Lior W.

unread,
Jun 18, 2021, 2:13:11 PM6/18/21
to GAM for Google Workspace
Documenting it for the future since it was sent privately:
gam config csv_output_header_filter "User,Date,Subject,From" redirect csv ./SentByDelegates.csv multiprocess csv Delegates.csv gam user "~delegate" print messages query "in:sent after:2021/06/01 before:2021/06/02 from:sha...@domain.com 

James SEYMOUR

unread,
Jun 30, 2021, 2:22:08 AM6/30/21
to GAM for Google Workspace
Hi Ross,

Just checking this and I think different time zones will affect results, but I can't remember what I need to do to rectify this. I have timezone = +08:00 in my GAM Config (as we are GMT +8) so thought this would deal with the timezone difference.

But when I run your command I get a single result (1 person sent 1 email). But when I search in:sent after:2021/06/01 before:2021/06/02 in the delegated Gmail inbox box there are 11 messages (with conversation view turned off).

The messages at the top is the one picked up by the command. The time stamp on this message is Tue, 1 Jun 2021 18:11:42 +0800. The next message is Tue, 1 Jun 2021 13:51:22 +0800.

Do I need to specify the after & before with a timezone offset or is this a bug?

Cheers

James

Lior W.

unread,
Jun 30, 2021, 8:19:13 AM6/30/21
to GAM for Google Workspace
Can you try in the UI with conversation view turned on? I understand in API it will always be on, so you must match.

Brian Kim

unread,
Jun 30, 2021, 10:20:17 AM6/30/21
to GAM for Google Workspace
In Gmail query, you are searching as the user. So wouldn't it be specific to the timezone that's set on the user's mailbox?
Or looks like it might default to PST

Ross Scroggs

unread,
Jun 30, 2021, 3:46:21 PM6/30/21
to google-ap...@googlegroups.com
James,

Try 6.04.19.

Updated processing of `query <QueryGmail>` that contains `(after|before|newer|older):YYYY/MM/DD`

so that GAM results match Gmail results. `YYYY/MM/DD` is interpreted as midnight on the given

date but GAM has to adjust the time to be consistent with `gam.cfg timezone`.


Ross


Jerudong International School
https://www.jerudonginternationalschool.com
Follow us on:
http://www.facebook.com/jisbruneidarussalam http://www.twitter.com/jisbrunei http://www.instagram.com/jisbrunei https://www.youtube.com/user/JISBrunei https://www.flickr.com/photos/133960569@N03/albums

--
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.


--

Brian Kim

unread,
Jun 30, 2021, 4:07:43 PM6/30/21
to GAM for Google Workspace
Wow, thanks Ross! you make it look so easy ;) it was just an idea in my head.

James SEYMOUR

unread,
Jun 30, 2021, 7:35:03 PM6/30/21
to GAM for Google Workspace
@Lior, with conversation view on I get 9 results. 2 of the messages have threads in the same day.
@Brian, the command is searching the delegated mailbox, so the settings of the individual, sending from the delegated mailbox, should not affect things. But I will look into PST timezone.
@Ross, I have updated but still getting the same output.

James SEYMOUR

unread,
Jun 30, 2021, 7:57:13 PM6/30/21
to GAM for Google Workspace
@Ross, using Epoch time (https://www.epochconverter.com/), which is assume is what Google is refering to on the link that @Brian gave, I still get the same results.

1st June 2021 12am My local time = 1622476800
2nd June 2021 12am My local time = 1622563200

gam redirect csv ./SentByDelegates.csv multiprocess csv delegates.csv gam user "~delegate" print messages query "in:sent after:1622476800 before:1622563200 from:<Delegated Email>" countsonly

Ross Scroggs

unread,
Jul 1, 2021, 10:36:38 PM7/1/21
to google-ap...@googlegroups.com
Lior/James,

6.04.20 can now do this.

gam redirect csv ./SentByDelegates.csv multiprocess csv Delegates.csv gam user dele...@domain.com print messages query "in:sent after:2021/06/01 before:2021/06/02" sendermatchpattern "~delegate" countsonly

Ross

Ross Scroggs

unread,
Jul 1, 2021, 10:54:42 PM7/1/21
to google-ap...@googlegroups.com
Lior/James,

Sorry, drop countsonly

6.04.20 can now do this.

gam redirect csv ./SentByDelegates.csv multiprocess csv Delegates.csv gam user dele...@domain.com print messages query "in:sent after:2021/06/01 before:2021/06/02" sendermatchpattern "~delegate"

James SEYMOUR

unread,
Jul 1, 2021, 10:58:08 PM7/1/21
to GAM for Google Workspace
Hi Ross,

Almost there :) the the output lists the dele...@domain.com as the user, where we really need the ~delegate user. Is this possible to extract and replace in the CSV?

Ross Scroggs

unread,
Jul 1, 2021, 11:00:50 PM7/1/21
to google-ap...@googlegroups.com
James,

Graack!  I'm fixing it right now.

Jerudong International School
https://www.jerudonginternationalschool.com
Follow us on:
http://www.facebook.com/jisbruneidarussalam http://www.twitter.com/jisbrunei http://www.instagram.com/jisbrunei https://www.youtube.com/user/JISBrunei https://www.flickr.com/photos/133960569@N03/albums

--
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.

James SEYMOUR

unread,
Jul 8, 2021, 8:47:01 PM7/8/21
to GAM for Google Workspace
Hi Ross,

Many thanks, I can confirm it is working now. In my example the SentByDelegates.csv file looked like this. 

$ more SentByDelegates.csv
User,Sender,messages
<Delegated Email>,<Sender 1 email>,1
<Delegated Email><Sender 2 email>,10

For those following this, Ross has to do some 'scripting magic' to acheive this. It would have been much easier if the sender could be used in Gmail searches, so I have submitted this as a feature request. If you think this would be a useful feature for Gmail (and associated GAM commands) please upvote here https://www.googlecloudcommunity.com/gc/Feature-Ideas/Include-sender-in-the-Gmail-search-operator/idi-p/163427.

Cheers

James

James SEYMOUR

unread,
Jul 8, 2021, 9:41:00 PM7/8/21
to GAM for Google Workspace
And, I have managed to combine commands (through trial and error so please doublecheck) to create a single command that will get the Delegates and then show the counts. You will need to change the dates accordingly.

gam user <Delegated Email> print delegates | gam redirect stderr - multiprocess redirect csv ./SentByDelegates.csv multiprocess csv - gam user <Delegated Email> print messages query "in:sent after:2021/06/01 before:2021/06/02" sendermatchpattern "~delegateAddress" countsonly todrive

If you remove the todrive you need to check the SentByDelegates.csv to see the results.

Cheers

James
Reply all
Reply to author
Forward
0 new messages