Programmatically specify sender e-mail address for My Site e-mail notifications in SharePoint 2010




In SharePoint 2010 open the Application Management section in the Central Administration, click on Manage Service Applications. Click on User Profile Service application. Go to My Site Settings, click on Setup My Sites.

In this you could see an option My Site e-mail notifications which is used to specify an e-mail address to use as the sender e-mail address for My Site e-mail notifications.


Code Snippet:

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using Microsoft.SharePoint;

using System.Web;

using Microsoft.Office.Server.UserProfiles;

 

namespace MySiteEmailSenderName

{

    class Program

    {

        static void Main(string[] args)

        {

            using (SPSite site = new SPSite("http://serverName:60001/sites/TestSiteColl"))

            {

                SPServiceContext context = SPServiceContext.GetContext(site);

                UserProfileManager upm = new UserProfileManager(context);

                upm.MySiteEmailSenderName = "[email protected]";

            }

        }

    }

}

Ebook Download
View all
Learn
View all