To provide users with e-mail notifications when an activity occurs in Collaboration, use a subscription. The IProjectManager interface allows you to query current subscriptions, and subscribe and unsubscribe users to Collaboration projects. You can also subscribe users to individual project components.
To subscribe a user to a project or project component, follow the steps below.
Java
... //userID1 and userID2 are both valid int user IDs that have not been added to any project roles int[] validUserIDs = new int(userID1, userID2); IRole guestRole = project.getRole(RoleType.GUEST); //Add the two users to the GUEST role. guestRole.addMember(userID1, MemberType.USER); guestRole.addMember(userID2, MemberType.USER); guestRole.store(); //Subscribe the two users to the task list. //No store() needs to be called after the call to subscribeUsers. tasklistManager.subscribeUsers(tasklist, validUserIDs); ...
.NET (C#)
... //userID1 and userID2 are both valid int user IDs that have not been added to any project roles int[] validUserIDs = new int(userID1, userID2); IRole guestRole = project.GetRole(RoleTypes.Guest); //Add the two users to the GUEST role guestRole.AddMember(userID1, MemberTypes.User); guestRole.AddMember(userID2, MemberTypes.User); guestRole.Store(); //Subscribe the two users to the project, set notifyForAllCreation setting to true, //so the two subscribed users will get notified upon all new object creations in this project. //No Store needs to be called on the project after the call to SubscribeUsers. projectManager.SubscribeUsers(project, validUserIDs, true); ...