The following code, though run with elevated privildges, redirects to an access denied error page saying "You are currently signed in as: (my non-admin account)." What am I doing wrong?
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPGroup group = SPContext.Current.Web.Groups["Group Name"];
foreach (SPUser user in group.Users)
{
string email = CustomMethodGetsEmailFromProfile(user);
SPUtility.SendEmail(...);
}
});
If I comment out the foreach loop, it works fine but defeats the purpose. Recall, I'm getting access denied. There's a few null checks that I didn't include as I'm writing this from memory. Thanks in advance for any help.