Antivirus software scans outgoing and incoming emails for malicious attachments and links. It uses a database of known malware signatures and heuristic analysis to identify potential threats. When a threat is detected, the software quarantines or deletes the suspicious email to prevent infection.