The Neumann problem for Laplace's equation in a polygonal domain is associated with the exterior Dirichlet problem obtained by requiring the continuity of the potential through the boundary. Then the solution is the simple layer potential of the charge q on the boundary. q is the solution of a Fredholm integral equation of the second kind that we solve by the Galerkin method. The charge q has a singular part due to the corners, so the optimal order of convergence is not reached with a uniform mesh. We restore this optimal order by grading the mesh adequately near the corners. The interior Dirichlet problem is solved analogously, by expressing the solution as a double layer potential.