Viruses are usually malicious computer programs which are able to alter programs and operating systems with its own code. Viruses can self replicate and attach code that can later be transmitted through emails.
Worms are another type of self-replicating that don't need to attach themselves to a program. Unlike viruses, worms dont usually alter the host operating systems or files, but can create backdoors that compromise the security of the host computer. Worms can also do damage by consuming bandwidth and are used to spread botnets that can be directed to send spam emails. Botnets are also used for Denial Of Service attacks that can "clog up" traffic to a website by repeated sending page requests to web servers.
Another common type of malware are Trojan Horses or simply Trojans. Trojans are mainly used to create backdoors, that allow unauthorized remote access to a host computer.