Although this has been pretty well addressed already, I thought I should post as the problem is actually very simple conceptually.
First, forget about the z axis, and work out your horizontal distance from the object using simple pythagoras.
eg. You are are (100,100), your target is at (200,200).
Distance = √( (200-100)^2 + (200-100)^2)
(Horizontal) Distance = √(200)
Now, suppose your z value is 100, and your target's is 200. Vertical distance is (200-100) = 100. Therefore you have a simple right angled triangle.
Using inverse tan you can find the required angle.
So breaking up a 3d problem into 2 2d ones makes it much simpler.
Hopefully this post helped.