We develop a general quantum mechanical method to calculate the dispersion relations of polariton modes for a quantum well embedded in a semiconductor planar microcavity. The method is based on the properties of the Green's function;of the electromagnetic field in a one dimensional dielectric structure. By means of this approach it is possible to express the dispersion relations in a compact form once the eigenmodes of the electromagnetic field in the region where the quantum well is placed are known. We discuss the specific example of a microcavity with equal distributed Bragg reflectors at the two ends. The dispersion relation in this case is calculated analytically. The method can in principle be applied to dielectric one dimensional structures of arbitrary dielectric profile.