Question about email attachments and viruses

In Yahoo mail whenever I get photos I can usually see them when I simply open the mail and don’t have to open the attachment. Does this mean that if I received a virus in an email attachment that I would “open” it just from opening the message itself or would I have to actually open the attachment?

No, it only displays JPG and GIF files in the HTML page. It does not (and cannot) execute a program in your computer.

I agree with sailor for garden variety executable attachments, but I’m not sure that’s entirely true for all situations, although I’m not knowledgeable enough to give a specific refutation. But if your email client supports HTML format, there are things that can be put in HTML that might do unwanted things. I think the techniques involve exploiting obscure security holes in the email client or browser rather than straightforward code. It may not kick in unless you actually click on a link on the page; as I said, I’m not sure. And I think this is rather rare.

This is not quite the same as a virus attachment, which is typically a .exe or .scr file that indeed you must explicitly execute for it to run.