There is a difference between Hacking and a Virus.
Any AV program would not have prevented your current problem.
I doubt that it was your machine that was hacked, it is much more likely to be your email supplier, Yahoo, Hotmail, AOL, etc.
If your email is one of those types, then it was your account that was hacked at the web site.
As Jimmy mentioned, strong passwords are a good step toward security. A mixture of upper & lower case, number and special characters and at least 8 characters long, is a good start.
A person I know, recently had their Yahoo account hacked and all sorts of emails were send to everyone in their addressbook.
There has been a lot of it going around over the last couple of months.
Who is your email with and who is your internet service provider?