1

I want to send mail to selected user in people picker control and CC to the his manager. Able to send the email to user. But how to get his manager email Id in C# Web part? Basically How to distribute groups according to department and further users in group based on role like manager, developer, team lead and so on?

  • c# means do you want code sample in server side coding..? – TARUN Mar 24 '17 at 8:01
0

1)You can maintain all manager's of employee in User Profile and can send mail from getting user profile properties of that employee.

2)Or you can maintain all details of employee in separate list an get the details from it.

for getting user profile you refer link

0

please check the below sharepoint stackexchange post Get Current User's Department Name and Manager From Active Directory. Instead of current user please pass the people or person column user identiy

 SPSite _site = SPContext.Current.Site;
   ServerContext serverContext = ServerContext.GetContext(_site);
   UserProfileManager myUserProfile = new UserProfileManager(serverContext);
   UserProfile currentUserProfile = myUserProfile .GetUserProfile(System.Web.HttpContext.Current.User.Identity.Name);

   string departmentName = (string)currentUserProfile["department"].Value;
   string managerName = (string)currentUserProfile["manager"].Value;
   _site.RootWeb.Dispose();
   _site.Dispose();
string managerName = (string)currentUserProfile["manager"].Value;    
SPFieldUserValue _spUserValue = new SPFieldUserValue(myWeb, managerName);    
SPUser myUser = _spUserValue.User;
  • thanks for reply, your answer may be great for those user who are using active directory. – Milan Raj Jun 15 '17 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.