AssignedTo and getting the person programatically
-
Wednesday, July 11, 2012 8:33 AM
Hi
I've created a timer job that looks at a Calendar List. The list has a AssignedTo field.
I want to email the person in the AssignedTo field.
Using
string taskassign = Convert.ToString(curItem["AssignedTo"]); gives 8;#Jane MaryI could use string manipulation to get the name in the format and email. I was thinking perhaps I could get the email instead or use SPUser class.
Any ideas on best approach ?
Thanks
All Replies
-
Wednesday, July 11, 2012 8:51 AM
Hi orange,
Try this..
string strUserValue = oList["Assigned To"]; int intIndex = strUserValue.IndexOf(';'); int intID = Int32.Parse(strUserValue.Substring(0, intIndex)); SPUser oUser = oWebsite.SiteUsers.GetByID(intID); string stremail = oUser.Email;Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact ravimca@live.com.
- Marked As Answer by orange juice jones Wednesday, July 11, 2012 9:06 AM
-
Wednesday, July 11, 2012 8:55 AM
Hi,
This code snippet could help you easily gets the User from Person/Group field in SharePoint list.
SPFieldUserValue userField = (SPFieldUserValue)list.Fields["Assigned To"].GetFieldValue(item["Assigned To"].ToString()); SPUser user= userField.User;
After that you will be able to use SPUser.Email PropertyDmitry
Lightning
Tools Check out our SharePoint tools and web parts |
Lightning Tools Blog- Marked As Answer by orange juice jones Wednesday, July 11, 2012 9:06 AM

