1

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

1 Answer 1

1

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

1
  • 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! Nov 30, 2012 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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