1

I have a list(registration) with fields like username,pwd ,name,age etc.

i want to send a mail to admin with all the fields (username,pwd,age etc...) when a new item is added to the custom list.i tried by using added event but i am unable to get the values of the newly added item.

it is entering into the if loop but at the next line i am getting an error object reference not set to any instance.

Thanks in advance

i am new to SharePoint

  public override void ItemAdded(SPItemEventProperties properties)
   {
       base.ItemAdded(properties);
       SPWeb oSPWeb = properties.OpenWeb();

       //GETTING THE LIST NAME
       String curListName = properties.ListTitle;         


       if (curListName == "registrtion")
       {
           //FETCH THE DATA OF THE NEW ADDED ITEM IN THE LIST
          string EMPLOYEENAME = properties.AfterProperties["EMPLOYEENAME"].ToString();
        }
   }
Jignesh Rajput
  • 3,538
  • 30
  • 50
user1716577
  • 29
  • 1
  • 7

1 Answers1

2

Use this instead:

string EMPLOYEENAME = properties.ListItem["InternalFieldName"]

Make sure you use the internal name of the field, check here how to get that name:

http://sharepoint-works.blogspot.com.au/2012/06/internal-column-name-in-sharepoint-list.html

Luis
  • 5,979
  • 2
  • 31
  • 51