Wednesday, November 28, 2012

Project Server 2010 - Send email to members of a group

Managing groups from code behind is very easy in Sharepoint. If you want to send email to every user of Sharepoint group, that is also very easy; you just get SPGroup by its name, loop through members of that group and and fetch their emails or some other property directly.

But, if you try doing that with Project Server, you'll find that it is a hard nut to crack. Project Server groups do not have same properties as Sharepoint groups do. So, if you want to access different user properties, you can use web services of Project Server SDK. They are not easy to configure and documentation is also confusing. I have described an easier way of configuring PSI functions in this post, with some examples.

Only way of accessing group data is directly accessing Project Server database and you don't need to use web services at all. This is an easy way.

If you need to fetch emails of all users of a Project Server group, you can do it with this SQL:

SELECT [WRES_EMAIL]
FROM [ProjectServer_Published].[dbo].[MSP_RESOURCES]
WHERE RES_SECURITY_GUID IN (
    SELECT [WRES_GUID] 
    FROM [ProjectServer_Published].[dbo].[MSP_WEB_SECURITY_GROUP_MEMBERS]
    WHERE WSEC_GRP_GUID = (
        SELECT [WSEC_GRP_GUID]
        FROM [ProjectServer_Published].[dbo].[MSP_WEB_SECURITY_GROUPS]
        WHERE WSEC_GRP_NAME = 'GroupName'))

This query will return all emails of users of a group named "GroupName".

No comments:

Post a Comment