The Wiener index of a graph is the sum of all pairwise distances of vertices of the graph. In this paper, we characterize the trees which minimize the Wiener index among all trees of given order and maximum degree and the trees which maximize the Wiener index among all trees of given order that have only vertices of two different degrees.