Yes, but only under specific conditions

You can get a virus from an email, but not straightforward by reading the message itself. Opening an email in your inbox and reading the text is safe. The risk comes from attachments — files sent with the email — or from clicking links inside the email that lead to malicious websites.

Modern email clients like Gmail, Outlook, and Apple Mail have built-in protections that scan attachments and block many dangerous files before they reach you. However, these filters are not perfect. A virus can still arrive if a sender's account is compromised, if the attachment is new enough that antivirus software does not yet recognize it, or if the email comes from someone you trust but whose computer is already infected.

The email itself — the words and formatting — cannot carry a virus. Email is plain text or HTML code. A virus is executable code, meaning it has to run as a program on your computer. That requires you to take an action: downloading an attachment, opening it, and running it.

Key Takeaways

  • Reading an email message is safe; the danger comes from opening attachments or clicking links inside emails.
  • Email attachments that are executable files — such as .exe, .bat, .scr, or .msi — are the most common way viruses spread through email.
  • Emails that appear to come from trusted senders can still carry viruses if that sender's account has been hacked or their computer is infected.
  • Your email provider scans many attachments automatically, but you should never open an attachment from an unknown sender or one you were not expecting.

How viruses travel through email attachments

A virus reaches your computer through an email attachment when you read and open the file. The most dangerous attachments are programs — files with extensions like .exe (Windows executable), .bat (batch file), .scr (screensaver), .msi (installer), or .zip (compressed folder that may contain programs). When you double-click one of these files, Windows runs the code inside, and if that code is malicious, it can infect your system.

Other file types can also carry viruses, though less commonly. Microsoft Office documents (.docx, .xlsx, .pptx) can contain macros — small programs embedded inside the file — that run automatically or when you enable them. Older versions of Office (2003 and earlier) were especially vulnerable. PDFs can theoretically carry malicious code, though it is rare.

The key point: the file has to be opened and, in some cases, the code inside has to be allowed to run. straightforward having the attachment in your inbox does not infect you.

Why emails from people you know can still be dangerous

You might receive a virus-carrying email from a friend, family member, or colleague. This does not mean they sent it intentionally. Their email account or their computer may have been compromised. A hacker with access to their account can send emails to everyone in their contact list, and because the email appears to come from someone you recognize, you are more likely to open the attachment.

This is one reason to be cautious even with familiar senders. If you receive an unexpected attachment from someone you know — especially if the message is brief, vague, or asks you to open a file urgently — contact that person through another method (a phone call, a text message, or a separate email asking about it) before opening the file. They may not know their account has been compromised.

What email providers do to protect you

Gmail, Outlook, Yahoo Mail, and other major providers scan incoming attachments using antivirus software. They block files they recognize as dangerous and may quarantine suspicious attachments so you cannot read them at all. Gmail, for example, does not allow you to read certain file types (.exe, .bat, .scr, and others) through its web interface, though you may be able to read them through a mail client like Outlook or Thunderbird.

These protections catch many threats, but they are not foolproof. New viruses are created constantly, and antivirus software relies partly on a database of known threats. A brand-new virus may not be in that database yet. Additionally, if a hacker compromises a legitimate business account and sends emails from that account, the email provider may not flag it as dangerous because the sender appears trustworthy.

Steps to protect yourself from email viruses

Do not open attachments from senders you do not recognize. If you receive an email from an unknown person with an attachment, delete it. Spammers and hackers often send thousands of emails hoping someone will open them.

Be cautious with attachments even from people you know, especially if the message is unexpected or seems out of character. A brief message like "Check this out" with an attachment is a common sign of a compromised account.

Keep your operating system and antivirus software up to date. Windows, macOS, and Linux all release security patches regularly. Antivirus programs like Windows Defender (built into Windows), Malwarebytes, or Norton update their threat databases constantly. These updates close vulnerabilities that viruses exploit.

Use caution with links inside emails. Clicking a link can take you to a fake website designed to steal your password or read malware. Hover over a link (without clicking) to see where it actually goes. If the URL does not match what the email claims, do not click it.

If you use an older version of Microsoft Office, disable macros by default. In newer versions, Office asks your permission before running macros, which gives you a chance to refuse if you were not expecting them.

What to do if you opened a suspicious attachment

If you opened an attachment and now suspect it may have been malicious, do not panic. Opening a file does not automatically infect your computer — the code usually has to run. If you opened a document (like a Word file or PDF) and straightforward read it, you are likely safe.

If you opened an executable file (.exe, .bat, .scr, or similar), your antivirus software should have caught it. Run a full scan of your computer using your antivirus program or Windows Defender. On Windows, open Windows Defender, go to Virus & threat protection, and click Scan options, then select Full scan.

If you are concerned about your email account being compromised, change your email password from a different device (not the potentially infected computer). Check your email's login activity or recent devices to see if anyone else has accessed your account. Most email providers show this information in account settings or security settings.

Frequently Asked Questions

Can you get a virus just by previewing an email in your inbox?

No. Previewing or reading an email message in your inbox is safe. The danger comes only from attachments or links. Some older email clients had vulnerabilities where straightforward viewing an email could trigger malicious code, but modern email clients have patched these flaws.

Is it safe to open a PDF attachment from an unknown sender?

PDFs are generally safer than executable files, but they can theoretically contain malicious code. If you were not expecting the PDF and do not know the sender, it is safer to delete it. If you do open it, your antivirus software should catch most threats.

What file types are safest to open from email?

Plain text files (.txt), images (.jpg, .png, .gif), and PDFs are among the safest. Executable files (.exe, .bat, .scr, .msi), compressed files (.zip, .rar), and Office documents with macros are riskier. When in doubt, do not open it.

Can you get a virus from clicking a link in an email?

Clicking a link itself does not infect you, but it can take you to a malicious website that tries to read malware or steal your information. Hover over links to see where they lead before clicking. If the URL looks suspicious or does not match what the email claims, do not click it.

Does my email provider protect me from all viruses?

Email providers block many known threats, but not all. New viruses are created constantly, and some may slip through. Your email provider is one layer of protection, but you should also keep your antivirus software updated and use common sense about which attachments you open.