How can retrieve email address from the Infopath people/Group picker?When I add the people/Group picker into the infopath form, I only get 3 fields DisplayName,AccountId,AccountType.Can anyone show me how can I get the email either by configurations or by code.

1 Answer 1


You can query the UserProfileService using the accountid from your people picker.

I wrote a simple class to do this from my form's code behind. Here's a quick sample with just the relevent bits (I'm typing from memory as I don't have the code in front of me, but you should be able to figure it out)...

First, add a web reference to your machine's UserProfileService

http://[your server]/_vti_bin/userprofileservice.asmx


class UserInfo
    private UPSvc.UserProfileService _svc = null;
    private UPSvc.PropertyData[] _pData = null; 
    private string _domainLogin = string.Empty;
    public WorkEmail = string.Empty;

    public UserInfo( string domainLogin )
        _domainLogin = domainLogin;
        _svc = new UPSvc.UserProfileService();
        _svc.UseDefaultCredentials  = true;
        _pData = _svc.GetUserProfileByName( domainLogin );

        int WORK_EMAIL = GetIndexOfProperty( "WorkEmail" );
        WorkEmail = GetADValue( WORK_EMAIL );


    private string GetADValue( int idx )
        return _pData[ idx ].Values[0].Value.ToString();

    private int GetIndexOfProperty( string propertyName )
        for( int i=0; i<_pData.Length; i++ )
            if( _pData[i].Name.CompareTo( propertyName ) == 0 )
                    return i;

        return -1;

To call...

UserInfo ui = new UserInfo( "domain\username" ); string email = ui.WorkEmail;

Hope that helps!

Cheers, Bob


Your Answer

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

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