Surface Integrals, Origin Located Outside and Inside the Surface. Given that $S$ is a smooth and closed surface in the $xyz$-space, that $\vec{n}$ is the unit outward normal vector to $S$, and $r$ the distance between the origin and a point $(x,y,z)$.
Evaluate the integral below $1)$ when the origin is outside and $2)$ inside $S$.
$$\int_S \nabla \left( \frac{1}{r}\right) \cdot \vec{n}dS$$
The problem is, I do not understand how the position of the origin will affect the surface integral. The only solution that I came up with was using Gauss' Theorem (or the Divergence Theorem).
Given that, from Gauss' Theorem,
$$\int_S \nabla \left( \frac{1}{r}\right) \cdot \vec{n}dS = \iiint_V \nabla^2 \left( \frac{1}{r}\right)dV$$
and
$$\nabla^2 \left( \frac{1}{r}\right) = 0$$
Thus,
$$\int_S \nabla \left( \frac{1}{r}\right) \cdot \vec{n}dS = 0$$
But I can not tell if this is right, if it is, why? This solution is for the origin at the inside or outside? How should I calculate the other (if the solution is for the outside case, how to compute the inside case, and vice-versa?).
 A: As stated in the comments, we cannot apply the divergence theorem directly to the surface integral $\iint_{S}\nabla(1/r)\cdot n\mathrm{d}S$ when $S$ encloses the origin. The divergence theorem requires that the the vector field $\nabla(1/r)$ be "nice" on the region of space enclosed by $S$.
We can, however, apply the generalized divergence theorem which allows us adjust the our domain of integration to a more suitable surface.
For example, if $S$ encloses the origin, find $\epsilon>0$ so that the sphere $$S_{\epsilon}=\{(x,y,z):x^2+y^2+z^2=\epsilon^2\}$$ is contained in the region of space enclosed by $S$. Take $E$ as the region of space inside $S$ and outside $S_{\epsilon}$. Then $\nabla(1/r)$ is smooth on $E$ so we can appeal to the divergence theorem. $$\iiint_{E} \nabla^2 (1/r)\mathrm{d}V = \iint_{S}\nabla(1/r)\cdot n\mathrm{d}S-\iint_{S_{\epsilon}}\nabla(1/r)\cdot n \mathrm{d}S$$ Here $n$ is normal to the surface and points away from the origin. Because $\nabla^2(1/r)\equiv0$ on $E$, $$\iint_{S}\nabla(1/r)\cdot n\mathrm{d}S=\iint_{S_{\epsilon}}\nabla(1/r)\cdot n \mathrm{d}S$$ Since $\nabla(1/r)=-\frac{1}{\epsilon^3}(x,y,z)$ and $n=\frac{1}{\epsilon}(x,y,z)$ for any $(x,y,z)\in S_{\epsilon}$ we get $$\begin{eqnarray*} \iint_{S}\nabla(1/r)\cdot n\mathrm{d}S &=&\iint_{S_{\epsilon}}\nabla(1/r)\cdot n \mathrm{d}S \\&=& \iint_{S_{\epsilon}}\left(-\frac{1}{\epsilon^3}(x,y,z) \cdot\frac{1}{\epsilon}(x,y,z)\right)\mathrm{d}S \\ &=& -\frac{1}{\epsilon^2}\iint_{S_{\epsilon}}\mathrm{d}S \\ &=& -\frac{1}{\epsilon^2}\cdot 4\pi \epsilon^2 \\ &=& -4\pi\end{eqnarray*}$$
