1

I am trying to use Google Apps Script to get the email delivery preference of members of a Google Group. This code:

AdminDirectory.Members.list()

gets the group members but I do not see an email preference. The info I am looking for is shown in the membership settings in groups.google.com.

Does anybody know how to get this in Apps Script?

Thanks for any tips or pointers

Scott
  • 477
  • 4
  • 20
  • If you check the Apps Script documentation, the only thing that you can get is the email of the group by using the [`getEmail()`](https://developers.google.com/apps-script/reference/groups/group#getEmail()) method. It will get this group's email address. For more information, check these SO question [27684315](http://stackoverflow.com/questions/27684315) and [38784889](http://stackoverflow.com/questions/38784889) on how to use `AdminDirectory.Members.list` in the Apps Script. You can verify here the only things that you can get by using this method. – KENdi Mar 09 '17 at 13:39
  • Well, my code works fine and I can see the fields returned. What I need is the missing "email preference" field (or whatever it is called). – Scott Mar 09 '17 at 15:29
  • I have the same question. @Scott: the field is called `delivery_settings` (shown [here](https://developers.google.com/admin-sdk/directory/v1/reference/members)). – Employee Oct 23 '18 at 21:27

1 Answers1

0

The Members.list method of the Admin Directory API does not return the delivery_settings field, but the Members.get method does.

So after getting the array of group members, loop through the members and get each member's delivery setting:

for (var i = 0; i < members.length; i++) {

  members[i]['delivery_settings'] = AdminDirectory.Members.get(groupEmail, members[i].email)['delivery_settings'];

}

Also, be aware that this has performance implications in Apps Script. Members.list is one API call, but Members.get will make another API call for each member of the group. This can cause your script to execute much slower if it runs on groups with a lot of members. You can monitor your script's performance using the Execution Transcript.

Employee
  • 2,231
  • 3
  • 33
  • 60