In general, it depends on the privacy laws in a particular country or state. Usually, you don’t have to mention it, but it is good practice to inform your contact how you obtained their details even if they don’t ask about it. However, If they do ask you, you should give them an honest answer.
Also, remember that you shouldn’t get in touch with people who haven’t expressed a willingness to be contacted by your company.