[Tex/LaTex] How to change the color of the hyperlink to mail address in moderncv class

colorhyperrefmoderncv

I am beginner in LaTeX, and experimenting with moderncv. I find that the hyperkink of the email is of the same light blue color as the surrounding info, failing to make clear that it is an hyperlink. A darker blue would be ideal. I have found below that one way to change this was to make a copy (and edit the copy) of the file moderncv.cls, into ie my moderncv.cls. I edited the two last lines below, and used the class mymoderncv but there is no change. I have tried the other suggestions without results either.
What is the correct procedure, if any?

Link formatting: colors, underlines in moderncv

\AtBeginDocument{
    \hypersetup{
      breaklinks,
      baseurl       = http://,
      pdfborder     = 0 0 1,
      linkcolor      = red

Best Answer

You can just wrap your \hypersetup command in \AtBeginDocument{...}. No need to fiddle with the .cls file:

\documentclass{moderncv}
\moderncvstyle{casual}       
\firstname{Mister}
\familyname{X}
\AtBeginDocument{
    \hypersetup{colorlinks,urlcolor=red}
}

\begin{document}
\makecvtitle

\section{Stuff}
\cventry{2012}{Accomplishment}{Institution}{City}{Country}{\href{mailto:mister@eggs.com}{Send me an e-mail!}}  
\end{document}

If you want to get underlined links, you can adapt the solution from How can I have colored and underlined links with hyperref?:

\documentclass{moderncv}
\moderncvstyle{casual}       
\firstname{Mister}
\familyname{X}
\AtBeginDocument{
\hypersetup{%
  colorlinks=false,
  urlbordercolor=red,% url borders will be red
  pdfborderstyle={/S/U/W 1}% border style will be underline of width 1pt
}
}
\begin{document}
Test
\makecvtitle

\section{Stuff}
\cventry{2012}{Accomplishment}{Institution}{City}{Country}{\href{mailto:mister@eggs.com}{Send me an e-mail!}}  
\end{document}