Class GroupsApp
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
그룹스앱
이 클래스는 Google 그룹스 정보에 대한 액세스를 제공합니다. 그룹의 이메일 주소 또는 사용자가 직접 회원으로 있는 그룹 목록과 같은 정보를 쿼리하는 데 사용할 수 있습니다.
다음은 현재 사용자가 구성원인 그룹 수를 보여주는 예입니다.
const groups = GroupsApp.getGroups();
Logger.log(`You belong to ${groups.length} groups.`);
자세한 문서
getGroupByEmail(email)
지정된 이메일 주소가 있는 그룹을 검색합니다. 그룹이 존재하지 않거나 그룹을 볼 권한이 없는 경우 예외가 발생합니다.
다음은 이메일 주소로 그룹을 가져오고 현재 사용자가 그룹의 구성원인지 여부를 출력하는 예입니다. 실행하기 전에 샘플 이메일 주소를 실제 그룹의 이메일로 바꿉니다.
const group = GroupsApp.getGroupByEmail('example@googlegroups.com');
const currentUser = Session.getActiveUser();
if (group.hasUser(currentUser)) {
Logger.log('You are a member of this group.');
} else {
Logger.log('You are not a member of this group.');
}
매개변수
이름 | 유형 | 설명 |
email | String | 검색할 그룹의 이메일 주소입니다. |
리턴
Group
: 지정된 이메일 주소가 있는 그룹입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/groups
getGroups()
내가 직접적인 회원 (또는 대기 중인 회원)인 모든 그룹을 검색합니다. 그룹에 가입하지 않은 경우 이 목록은 비어 있습니다. 그룹이 존재하지 않거나 그룹을 볼 권한이 없는 경우 예외가 발생합니다.
다음은 사용자가 속한 모든 그룹의 이메일 주소를 출력하는 방법의 예입니다.
function showMyGroups() {
const groups = GroupsApp.getGroups();
let str = `You are in ${groups.length} groups: `;
for (let i = 0; i < groups.length; i++) {
const group = groups[i];
str = `${str + group.getEmail()} `;
}
Logger.log(str);
}
다른 그룹 A의 구성원인 그룹 B의 구성원인 경우 그룹 A를
간접적으로 구독하게 됩니다. '상위' 그룹 A로 전송된 메일의 사본을 수신하더라도 실제로는 해당 그룹을 구독하지 않습니다.
Group.getRole(email)
를 사용하여 반환된 그룹의 기존 회원인지 또는 대기 중인 회원인지 확인할 수 있습니다.
리턴
Group[]
: 사용자가 직속 회원인 그룹 목록입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/groups
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
[null,null,["최종 업데이트: 2025-07-26(UTC)"],[[["\u003cp\u003eThe \u003ccode\u003eGroupsApp\u003c/code\u003e class in Apps Script allows you to access and manage Google Groups information, such as retrieving group details and membership status.\u003c/p\u003e\n"],["\u003cp\u003eYou can use \u003ccode\u003egetGroupByEmail()\u003c/code\u003e to retrieve a specific group by its email address and check if the current user is a member.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetGroups()\u003c/code\u003e retrieves all groups where the user is a direct or pending member, enabling actions like listing group email addresses.\u003c/p\u003e\n"],["\u003cp\u003eBoth methods require authorization with the \u003ccode\u003ehttps://www.googleapis.com/auth/groups\u003c/code\u003e scope for accessing Google Groups data.\u003c/p\u003e\n"]]],[],null,["# Class GroupsApp\n\nGroupsApp\n\nThis class provides access to Google Groups information. It can be used to query information such\nas a group's email address, or the list of groups in which the user is a direct member.\n\nHere's an example that shows how many groups the current user is a member of:\n\n```javascript\nconst groups = GroupsApp.getGroups();\nLogger.log(`You belong to ${groups.length} groups.`);\n``` \n\n### Properties\n\n| Property | Type | Description |\n|----------|--------------------------------------------|-------------|\n| `Role` | [Role](/apps-script/reference/groups/role) | |\n\n### Methods\n\n| Method | Return type | Brief description |\n|----------------------------------------------------|------------------------------------------------|----------------------------------------------------------------------------------|\n| [getGroupByEmail(email)](#getGroupByEmail(String)) | [Group](/apps-script/reference/groups/group) | Retrieves the group having the specified email address. |\n| [getGroups()](#getGroups()) | [Group[]](/apps-script/reference/groups/group) | Retrieves all the groups of which you are a direct member (or a pending member). |\n\nDetailed documentation\n----------------------\n\n### `get``Group``By``Email(email)`\n\nRetrieves the group having the specified email address. Throws an exception if the group does\nnot exist or if you do not have permission to see it.\n\nHere is an example that gets a group by its email address and outputs whether the current\nuser is a member. Before running, replace the sample email address with a real group's email.\n\n```javascript\nconst group = GroupsApp.getGroupByEmail('example@googlegroups.com');\nconst currentUser = Session.getActiveUser();\nif (group.hasUser(currentUser)) {\n Logger.log('You are a member of this group.');\n} else {\n Logger.log('You are not a member of this group.');\n}\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|---------|----------|---------------------------------------------|\n| `email` | `String` | The email address of the group to retrieve. |\n\n#### Return\n\n\n[Group](/apps-script/reference/groups/group) --- The group with the specified email address.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/groups`\n\n*** ** * ** ***\n\n### `get``Groups()`\n\nRetrieves all the groups of which you are a direct member (or a pending member). This is an\nempty list if you are not in any groups. Throws an exception if the group does not exist or if\nyou do not have permission to see it.\n\nHere's an example of how to print the email address for every group the user belongs to:\n\n```javascript\nfunction showMyGroups() {\n const groups = GroupsApp.getGroups();\n let str = `You are in ${groups.length} groups: `;\n for (let i = 0; i \u003c groups.length; i++) {\n const group = groups[i];\n str = `${str + group.getEmail()} `;\n }\n Logger.log(str);\n}\n```\nNote that if you are a member of a group, B, which is itself a member of another group, A, then you are *indirectly* subscribed to group A. Even though you receive copies of messages sent to the \"parent\" group A, you are not actually subscribed to that group.\n\nYou can use [Group.getRole(email)](/apps-script/reference/groups/group#getRole(String)) to determine if you are an existing or pending\nmember of the returned groups.\n\n#### Return\n\n\n[Group[]](/apps-script/reference/groups/group) --- The list of groups of which the user is a direct member.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/groups`"]]