Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a workflow in visual studio and I need to send an email to a domain user whose name is entered into a sharepoint Person or Group lookup. The value will not be in a sharepoint group, it is from an AD sync:

workflowProperties.Item["Project Manager"].ToString();

When I test it using smtp4dev in our dev environment, the email address is coming up strange so I am not sure if it will be sent in the production environment:

7 <7>; #Johnson <#Johnson>; Tim <Tim>

Do I have to do anything to extract the email address from the lookup column?

MOSS 2007
VS 2010

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

User Lookup column does not contain data about SPUser properties such as email, it contains user Id and Title only.

The string representation of user lookup column value will be "1;#John Doe", where ";#" is a delimeter.

From the code point of view, User lookup value is an SPFieldUserValue object. You can get user email as a property of SPUser object, but first you should retrieve it from current field value.

You can do it using the code,described in this article: http://jebass.blogspot.ru/2008/11/how-to-read-spuser-field.html

share|improve this answer
    
That did it! I needed this completed by the end of the day today and I have been looking for a solution for the past two days. Thanks! –  steveareeno Nov 30 '12 at 16:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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