[Tex/LaTex] Change color of just one hyperlink on moderncv

hyperreflinksmoderncv

I am using moderncv and I want to change the color of the mail address link in the personal section but I want the rest of the links on my cv to remain blue. Here's an example:

\documentclass[11pt,a4paper,dvipsnames]{moderncv}

\moderncvtheme[blue]{classic}
\usepackage[scale=0.8]{geometry}
\usepackage[utf8]{inputenc}

\firstname{First name}
\familyname{Last name}
\title{Curriculum Vitae}
\address{Address line 1}{Address line 2}
\mobile{Phone}
\email{Email}

\AtBeginDocument{\hypersetup{colorlinks, urlcolor=NavyBlue}}

\begin{document}

\cvitem{Email}{\emaillink{test@gmail.com}}

  \section{Education}
 \cventry{Year}{Degree}{University}{Location}{GPA. \href{http://www.google.com}{Google}}{}


\cventry{2012}{test}{test}{\texttt{\href{http://www.google.com}{click me}}}{}{}
\cventry{2012}{test}{test}{\texttt{\url{http://www.google.com}}}{}{}

\end{document}

So, I want the test@gmail.com to appear in black and the google ones to remain in blue. Is there a way to do this? thanks!

Best Answer

A solution could be to group an additional \hypersetup command just for the mail address:

\begingroup%
\hypersetup{urlcolor=black}%
\cvitem{Email}{\emaillink{test@gmail.com}}%
\endgroup%

This prevents another setup of hyperref later on.

\documentclass[11pt,a4paper,dvipsnames]{moderncv}

\moderncvtheme[blue]{classic}
\usepackage[scale=0.8]{geometry}
\usepackage[utf8]{inputenc}

\firstname{First name}
\familyname{Last name}
\title{Curriculum Vitae}
\address{Address line 1}{Address line 2}
\mobile{Phone}
\email{Email}

\AtBeginDocument{\hypersetup{colorlinks, urlcolor=NavyBlue}}

\begin{document}

\begingroup 
\hypersetup{urlcolor=black}%
\cvitem{Email}{\emaillink{test@gmail.com}}
\endgroup

  \section{Education}
 \cventry{Year}{Degree}{University}{Location}{GPA. \href{http://www.google.com}{Google}}{}

\cventry{2012}{test}{test}{\texttt{\href{http://www.google.com}{click me}}}{}{}
\cventry{2012}{test}{test}{\texttt{\url{http://www.google.com}}}{}{}

\end{document}

enter image description here