Skip to content

Instantly share code, notes, and snippets.

@ochilab
Created October 24, 2023 08:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ochilab/620d909c6a01ffecf7454bf26cdf41cc to your computer and use it in GitHub Desktop.
Save ochilab/620d909c6a01ffecf7454bf26cdf41cc to your computer and use it in GitHub Desktop.
GAS: Google Classroomの受講生のメールアドレスを取得する
function getUserEmailsInCourse(courseId) {
var emailList = [];
var nextPageToken;
do {
var response = Classroom.Courses.Students.list(courseId, {
pageToken: nextPageToken
});
var students = response.students;
if (students && students.length > 0) {
for (var i = 0; i < students.length; i++) {
var userId = students[i].userId;
var email = students[i].profile.emailAddress;
emailList.push({
userId: userId,
email: email
});
}
}
nextPageToken = response.nextPageToken;
} while (nextPageToken);
return emailList;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment