As others have said, four hours is too little time to get through immigration, customs, train to Tokyo, train back and back through immigration and security.
If you had more time... and you took a quick trip to Tokyo and back with express trains (i.e. Narita Express or Keisei Skyliner) you would have to buy tickets for both legs of the journey (Narita to Tokyo and Tokyo to Narita).
I suggest that you use one of the delivery services (Takuhaibin) from Narita arrivals hall - They will charge about 2000yen to deliver up to 25Kg from NRT to an address in the Tokyo area. (Less if your package is smaller). That's actually cheaper than taking the N'EX into Tokyo.
Or... If the delivery is urgent, then you should ask your friend to come to meet you at NRT during your stopover.