Export (0) Print
Expand All

SPUser.Email Property

Gets or sets the e-mail address of the user. (Read-only in sandboxed solutions.)

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

[ClientCallableConstraintAttribute(Type = ClientCallableConstraintType.MaxLength, Value = )]
[ClientCallableAttribute]
[ClientCallableConstraintAttribute(Type = ClientCallableConstraintType.NotNull, Value = )]
public string Email { get; set; }

Property Value

Type: System.String
A string that contains the e-mail address.

To modify the e-mail address for a user by setting the value of the Email property, call the Update method to effect the changes in the database.

The following code example modifies the e-mail address for a specified user object.

SPSite oSiteCollection = SPContext.Current.Site;
using (SPWeb oWebsite = oSiteCollection.AllWebs["Website_Name"])
{
    SPUser oUser = oWebsite.AllUsers["User_Name"];

    oUser.Email = " E-mail_Address";

    oUser.Update();
}
NoteNote

Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects.

Show:
© 2014 Microsoft