Accept gifts
To use a gift, the first thing you'll need to do is to retrieve the gift from the inbox. The inbox is the yellow envelope located in the top right of your screen.

Tap on the envelope and there you can accept gifts by tapping on the green accept button. When you are accepting gifts, you can also send back coins to thank the player who's sent you the gift. Both cases are shown in the picture below.
 
Use gifts
Once you have accepted items, they will appear in your gift box. To access your gift box, tap on the present box at the bottom right of the screen.
 
In the gift box, some items will have the "Use" option under them. This means you can use them to help complete a building or machine. 
 
When you tap on "Use" and you have an incomplete building or machine on your farm, a picture of the incomplete buildings or machines will be displayed. Tap on the picture to add the item. If you don't have a building or machine that needs the part, you will be prompted that you'll need to start the construction on the building or machine first.
 
 
 
Trading Items
If you receive items from your neighbors that you no longer need, the option to trade the item for coins will appear below the picture of the item.
 
 
When you tap on the trade button you can select the quantity to trade by using the slider. If you only have 1 of an item in the inbox, tapping trade will immediately trade the item. Tap the green "Trade" button to confirm the trade or the X to cancel and go back to your gift box.