简体   繁体   中英

How to get 'All new users' in the Google Apps domain Apps Script

I would like all new users who's being created in the domain should be greeted with a welcome message (Email).

So i need to do two things.

  1. Get all 'new users' This gets all users in the domain, but I would like only the new one.
  var users = UserManager.getAllUsers(); 

2.Send Email to them

>   for (var i in users) {
>         MailApp.sendEmail("message", "emailSubject", "emailText"); 
>          }

I'm not sure if you can return a date for when a new account became active using UserManager (I couldn't find anything in the any of the 'Domain' classes documentation).

The way in which I would approach this is to run an extract of all users once to get a baseline array then run the same extract of users at a later date. Any new accounts will be in the second extract not the first and you can email accordingly. After this the second extract becomes the current one and you bin the first.

Alternatively, you can download a .csv of account activity from the admin console which does show when the account became active and run a script on that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM