Expressing in terms of complex exponentials is a good start. You used
$$\cos(kx)=\frac{e^{ikx}+e^{-ikx}}{2}.$$
Now $\sum_{k=1}^n e^{ikx}$ is the sum of a finite geometric series, as is the sum of the other terms. So our sum is equal to
$$\frac{1}{2}\left(\frac{e^{ix}(1-e^{inx})}{1-e^{ix}}+\frac{e^{-ix}(1-e^{-inx})}{1-e^{-ix}}\right).$$
You are probably expected to express things in terms of real functions. So bring to a common denominator. At the bottom we get $(1-e^{ix})(1-e^{-ix})$. If you multiply this out and recognize that $e^{ix}+e^{-ix}=2\cos x$, you end up with $2-2\cos x$. If you feel like it, this can be in a sense simplified by using the identity $\cos 2\theta=2\cos^2\theta-1$.
After you bring things to a common denominator, expand the messy top that you get. It is easy, but with ample opportunities for error. The terms you get combine nicely in pairs into (twice) cosines, apart from a couple of terms that are each simply $-1$.
The above calculation works when $1-e^{ix}\ne 0$ ($\cos x\ne 1$). For completeness, we need to deal with the case $\cos x=1$. In that case the sum is $n$.