How to send email to People or group field user
People/Group field in SharePoint allow us to keep adding the existing user(s) or group(s) into the document library or list item. Let’s think, I have a list where one field name i.e. Assigned To (reviewer) is type of People/Group. Objective is when I assign someone to review the list item, and then an email notification needs to be fired up to that reviewer.
In other words, you have to find that person from the UserCollection list in SharePoint and send an email to that associated person.
Now once you assign one person on this field, you will found how the SharePoint display his/her name in the New/Edit OTB form and it is like DOMAIN\LOGINNAME. So if your domain name is SP-SERV and your name is Himadrish Laha, it will be looks like SP-SERV\Himadrish Laha.
Below the simple code I have used to fetch the string data and it returns me something else which I found in the debugging mode “1;#SP-SERV\\kiran” (here I have added user Kiran). When I have added my name it looks like “16;#SP-SERV\\Himadrish Laha“. String represent is kind of <UserID>;#<UserLoginName>.More difficult for you to work.
My initial thought is to split the string value and use the UserID. However latter I found this is not the actual UserID associated with the user, instead of this, it is kind of index ID associated with this user in SharePoint. So, if you try to use this ID as below, I bet you will found different user in SPUser object. So the following code is incorrect to trap actual user:
string UserAccount = _ListItem["Assigned To (Reviewer)"].ToString();
int UserID;
if (UserAccount.Trim() != string.Empty)
{
UserID = Convert.ToInt32(UserAccount.Substring(0, UserAccount.IndexOf(“;”)));
SPUser _SPUser = properties.OpenWeb().Users[UserID];
string UserEmail = _SPUser.Email.ToString();
}
What we have left now is only the login display name. Here is also one drawback to trap the user. This string is Login Display Name and it is not the LoginID. So if my login id is Himadrish.Laha and my display name is Himadrish Laha, it will show me Himadrish Laha in the People filed control text box. Note the missing of the DOT (.). For people having same string in loginID as well as Login Display name shouldn’t be a problem, but for other it will make a big difference.
To resolve this issue, the following code may help you. In most of the cases, you can simply add one DOT (.) in between user’s given name and his/her family name. Inside the code, the web represent the SPWeb object. So the method is being used here is SPWeb.EnsureUser(). You need to pass user’s login id over there, and it will return you SPUser object.
string UserAccount = _ListItem["Assigned To (Reviewer)"].ToString();
string UserLogin;
string UserEmail = string.Empty;
if (UserAccount.Trim() != string.Empty)
{
UserLogin = UserAccount.Substring(UserAccount.IndexOf(“#”), (UserAccount.Length – UserAccount.IndexOf(“#”)));
UserLogin = UserLogin.Replace(“#”, “”).Replace(“;”, “”);
UserLogin = @”SP-SERV\” + UserLogin.Replace(” “,”.”);
SPUser _SPUser = web.EnsureUser(UserLogin);
UserEmail = _SPUser.Email.ToString();
_SPUser = null;
}
Kindly note, the above code may need to change according to get the login id from the login name. If in your organization the login id is something the first character of your given name i.e. H for Himadrish and then your last name i.e. Laha, then your login id would be HLAHA. So you need to change the above code and found the actual login id what it would be. Rest of the line would be same.
Hopes this will help you.


Awesome informative post. Thanks for helpful article.
I’ve got to write about this for a course Im taking, well related to this. This really made it easier for me , so thanks you A TON.Take care, Tony Cyganiewicz
Thank you for the good writeup. It in fact was a amusement account it. Look advanced to more added agreeable from you! However, how could we communicate?
Really great informative blog post here and I just wanted to comment & thank you for posting this. I’ve bookmarked youi blog and I’ll be back to read more in the future my friend! Also nice colors on the layout, it’s really easy on the eyes.
When I originally commented I clicked the -Notify me when new comments are added- checkbox and now each time a comment is added I get four emails with the same comment. Is there any way you can remove me from that service? Thanks!
I think you write this blog from a different point of view on the subject, which is rather unique from most other blogs. I welcome your difficult work on it.
I am not sure where you are getting your information, but great topic. I needs to spend some time learning more or understanding more. Thanks for excellent information I was looking for this information for my mission.
Ernest Hemingway~ Theres nothing noble in becoming superior to your fellow males. True nobility is being superior for your former self.
I used to be very happy to find this web-site.I wanted to thanks in your time for this glorious learn!! I undoubtedly having fun with every little little bit of it and I have you bookmarked to take a look at new stuff you blog post.
This web site is actually really very helpful for some1 whom has been having problems with this scenario. I have looked at a bunch of resources nonetheless to no avail. I may continue reading through and learning here in the desire of in the long run get beyond this.
Awesome idea I love this
Hi. Thanks for this post. My cousin recommend me this site and now I’m totally agree with her. I’ve bookmarked your site and I hope you will keep on writing.
Nice submit! GA can also be my greatest earning. On the other hand, it’s not a a lot.
There are some interesting points in time in this article but I don’t know if I see all of them center to heart. There is some validity but I will take hold opinion until I look into it further. Good article , thanks and we want more! Added to FeedBurner as well
You made some decent points there. I looked on the internet for the issue and found most individuals will go along with with your website.
Superb publish, I have been looking into this good recently. Fascinating to hear some a lot more information on this. Keep up the extremely operate!
Good Stuff appreciate the insight, I will be back!! A~
Excellent beat ! I would like to apprentice while you amend your web site, how can i subscribe for a blog website? The account helped me a acceptable deal. I had been a little bit acquainted of this your broadcast provided bright clear concept
I Will have to return again when my course load lets up – nevertheless I am getting your Rss feed so i could go through your site offline. Thanks.
Author of this site is really professional staff. There are wonderful ingredients.
The archetypical moment I had ever seen grouping same this web place
Brilliant post, thanks ever so much for your thoughts. I think I’ll be forced to implement this in future.
On the praise of a person I care to this supplying. Real extraordinary.
Hello, I am sorry for being offtopic but what theme do you use? did you create it yourself? I like the theme you are using. I believe I saw one similar to your blog but I dont remember .
I simply had to appreciate you yet again. I do not know what I might have worked on in the absence of those aspects contributed by you on that industry. It was an absolute horrifying situation for me personally, however , witnessing your well-written form you solved that made me to leap over happiness. I am just happy for the assistance and then expect you comprehend what an amazing job you’re carrying out educating most people through your websites. I know that you have never encountered any of us.
That’s incredible!
You sure do know what youre talking about. Man, this blog is just great! I cant wait to read more of what youve got to say. Im really happy that I came across this when I did because I was really starting to get bored with the whole blogging scene. Youve turned me around, man!
very good post, i actually love this web site, carry on itIt’s laborious to find educated people on this subject, but you sound like you realize what you’re talking about! Thanks
This so nice
There are certainly a couple more details to take into consideration, but thank you for sharing this information.
There are certainly a couple more details to take into consideration, but thank you for sharing this information.
Dear admin, thanks for providing this blog post. I found it great. Take care,
Done well! Enjoyed checking out your post because of its terrific concepts and exceptional thoughts.
Many thanks for this valuable piece of writing. I undoubtedly enjoyed dealing with it and will definitely talk about it with everyone.
Great articles and nice a website design too
I honestly did not think this specific issue that way. I feel that there is certainly a point in all of this. Delighted to be in a position to get involved. Wish you good luck.
I have been browsing online more than 3 hours today, yet I never found any interesting article like yours. It is pretty worth enough for me. In my opinion, if all web owners and bloggers made good content as you did, the internet will be much more useful than ever before.
I actually didn’t think this specific situation that way. I feel that there may be a point in all of this. Delighted to be capable to get involved. Wish you luck.
hi thanks for your posts. can i ask somethink special ? did you make your website yourself ? if you are webmastering your site i think you did a greta well job espcially on your graphics wellnes.thanks again.
This is really interesting, You are a very skilled blogger. I’ve joined your rss feed and look forward to seeking more of your great post. Also, I’ve shared your website in my social networks!
a very good read very good blog will be looking out for more of these blogs
You sure do know what youre talking about. Man, this blog is just great! I cant wait to read more of what youve got to say. Im really happy that I came across this when I did because I was really starting to get bored with the whole blogging scene. Youve turned me around, man!
Good luck getting people behind this one. Though you make some VERY fascinating points, youre going to have to do more than bring up a few things that may be different than what weve already heard. What are trying to say here? What do you want us to think? It seems like you cant really get behind a unique thought. Anyway, thats just my opinion.
Keep working ,great job!
Great article…
some genuinely quality blog posts on this internet site , saved to favorites .
I reckon something genuinely interesting about your site so I saved to my bookmarks .
actually appreciated the article that you have written actually. it really isn’t that easy to find good text toactually read (you know.. really READ and not just browsing through it like a zombie before moving on), so cheers man for not wasting my time!
Thanks for taking the time to talk about this, I feel fervently about this and I take pleasure in learning about this topic. Please, as you gain information, please update this blog with more information. I have found it very useful. There have to be charging stations everywhere.
Dear admin, thanks for providing this blog post. I found it great. Take care,