Blog

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

Posted by Vijai Anand Blogs | SharePoint 2010 Nov 21, 2011
In this blog you will see how to specify an e-mail address to use as the sender e-mail address for My Site e-mail notifications in SharePoint 2010 using SharePoint Object Model.



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 = "anystring@somestring.com";

            }

        }

    }

}

COMMENT USING
PREMIUM SPONSORS
Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.
Employers - Post Free Jobs
SPONSORED BY
  • MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.