SPNote

SharePoint Notes

Set Email Notification values on a UserProfile

In OOTB SharePoint 2010, all the three options for Email Notifications are checked. This may help customers for collaboration but some others may think that they receive lots of unnecessary emails and get annoyed. If your company size is big enough like me (30,000+), your IT department manager will make a request for disabling all or some of them.

The request was to disable the last option.

  • Uncheck “Send me suggestions for new colleagues and keywords”

After searching on this, I found out that there is a nice one using PowerShell but I couldn’t find the how the option value is saved because the value has changed to a different value when I save it into the UserProfile. In addition, I wanted to add some features such as examining values, applying multiple sites and saving some information into a log file.

The simple application looks like below.
image

At first, I thought updating the options for the UserProfile should be easy but if you tried some combinations, you will realize saved values are somehow different than the value should be.

You may think the option value will be saved like this
[V] Notify me when someone leaves a note on my profile
[V] Notify me when someone adds me as a colleague
[   ] Send me suggestions for new colleagues and keywords
=> option  value: 110

image
# Binary and Decimal values

Surprisingly, you will notice the Email Notification setting value is 100 (SP) instead of 110 (UI) when you read it from SharePoint. I could figure out after trying several times with combinations

Now I am going to explain how the value is saved.

  1. Without conversions – think the other way
    1. Checked: 0, Unchecked: 1
    2. Concatenate the option values in opposite order
      - Concatenate them in descending order (from 3 to 1)
      image
  2. Convert UI one (110) to SharePoint one (100)
    1. Reverse the each options
    2. Reverse characters
      image

The option value 110 (UI Version) is saved into 100 (SP Version) and I have no idea why the developer is saved it this way. You may find a method for doing this from SharePoint dlls(Please let me know if you find it).

Some tips from my exprience are

  1. SPSEmailOptins value is null (default)
    - The value null means 111 (all of them will be checked)
    - Check the value is null when you read the value
      You can read the value once you saved it.
  2. Login as farm administrator account
    - you can add another account at UserProfileServiceApplication > Administrators for testing.
    image
  3. Check if user exists from UserProfileManager
    - UserProfileManager.UserExists(accountName)

I had a hard time configuring My Site and testing this app. My Site configuration was hard and took some time. I will write an article about it later.