Shubham Dixit, email forensics and data file expert

Written by Jennifer Walsh. Reviewed for technical accuracy by Shubham Dixit, Independent Expert in Email Forensics and Data File Conversion.

Shubham is an independent external reviewer and not an employee of PCDOTS.

Quick answer. There is no extract_attachments() method in the extract_msg library, which is why the AttributeError appears. The attachments sit in msg.attachments, so loop over them and call save on each. No code? Open the .msg in Outlook and save the attachments, or use a tool to pull them from many files at once.

The extract_msg AttributeError, and the fix

If you landed here from a Python error, this is the part you want. The extract_msg library reads Outlook .msg files, and a lot of people try to pull attachments with a call like msg.extract_attachments(), then hit AttributeError, Message object has no attribute extract_attachments. The reason is simple, that method does not exist. The attachments are not behind a method at all, they sit in a list called msg.attachments, and you save each one.

the call that fails msg.extract_attachments() ×AttributeError,no such method the real way for a in msg.attachments then a.save() oneach attachment

There is no extract_attachments() method, the attachments are the msg.attachments list.

“This error trips people up constantly in forensic scripting, and the fix is not a workaround, it is the actual design. extract_msg exposes attachments as a list on the message, not as a method you call, so the moment you loop msg.attachments and save each item the problem disappears. When I am processing a whole evidence set of .msg files rather than one, I move to a batch tool so nothing is missed and every attachment keeps its original name and type. But for a single file, the library is right there and free.” Shubham Dixit, Email Forensics reviewer (draft, pending approval)

Here is the whole thing. Install with pip install extract-msg, then loop the list and save.

import extract_msg

msg = extract_msg.Message("email.msg")

for attachment in msg.attachments:
    attachment.save(customPath="attachments")

Each item in msg.attachments is a real attachment, and save writes it to disk keeping its own name and extension. Pass customPath to send them all to a folder. That is the entire fix, no extra method needed.

The one-line command way

If you do not want to write a script at all, the same library ships a command. Point it at a .msg file and it builds a folder holding the message and its attachments.

python -m extract_msg email.msg

This is the fastest route for a one off, and it works the same on Windows, macOS and Linux wherever Python is installed.

No code, save them in Outlook

If you have Outlook and only a few files, you do not need any of the above. Double-click the .msg so it opens, then use File, Save Attachments, and pick a folder. You can also just drag an attachment straight out of the open message onto your desktop. Both pull the attachment out in its original format, for free, with nothing to install.

open the .msgin Outlook File, Save Attachmentsor drag the attachment outfree, keeps the format files in a folderPDF, DOCX, JPG and so on

With Outlook open, File then Save Attachments is the free no-code route.

Many MSG files at once

The routes above are perfect for one file or a quick script. When you have hundreds or thousands of .msg files and no wish to code, and maybe no Outlook either, doing it one at a time is the problem. A batch tool reads a whole folder of .msg files and pulls every attachment out together, in its original format. The PCDOTS MSG Converter does exactly that on Windows, no Outlook needed, with a preview and a free version so you can test a folder before you buy.

1Run itOn Windows,open the menu 2Add folderof .msgfiles 3AttachmentsFrom theExtract menu 4SaveTo a folderon disk iBest for a whole folder of .msg files, with no Outlook and no code.

The tool route, a folder of .msg files to their attachments in one pass.

Here are the steps with the screens.

Step 1. Install and run the software on Windows, then open the menu.

Run the MSG attachment extractor

Step 2. Choose MSG files and add the folder so the messages load.

Add the MSG folder

Step 3. Preview the messages, then open Extract and choose Attachments.

Preview MSG messages before extracting

Step 4. Pick the Attachments option and Save to a destination folder.

Choose Extract Attachments and save

For the same job on other formats, see our guides to extract attachments from PST files, extract attachments from EML files and extract attachments from DBX files.

Free Download
Buy Now

The methods compared

Pick by whether you code, and how many files you have.

Method Best for Good to know
extract_msg in Python Coders, automation Use msg.attachments, save each
Outlook Save Attachments A few files, free Needs Outlook installed
MSG Converter tool Many files, no code Windows, no Outlook needed

Frequently asked questions

Why do I get AttributeError, Message object has no attribute extract_attachments?
Because extract_msg has no extract_attachments() method. The attachments are in the msg.attachments list, so loop over that and call save on each item instead.

How do I save attachments with extract_msg?
Open the file with extract_msg.Message, then for each attachment in msg.attachments call attachment.save, passing customPath to choose a folder.

Is there a one-line way without a script?
Yes. Run python -m extract_msg yourfile.msg and it creates a folder holding the message and its attachments.

How do I extract attachments from an MSG file without any code?
Open the .msg in Outlook and use File then Save Attachments, or drag the attachment out of the open message. Both keep the original format.

How do I extract attachments from many MSG files at once?
Use a batch tool that reads a whole folder of .msg files and saves every attachment together, which avoids opening each one by hand.

Do the attachments keep their original file types?
Yes. Whether you use the library, Outlook or a tool, each attachment comes out in its own format, such as PDF, DOCX or JPG.

The one correction that fixes it

Almost everyone who hits this is one word away from done. There is no extract_attachments() method to call, the attachments are already sitting in the msg.attachments list, so you loop that and save each one. That single change clears the AttributeError for good. If you are not scripting at all, Outlook saves them for free through File then Save Attachments, and when it is a whole folder of .msg files a batch tool pulls every attachment at once. Same result each way, the message stays put and the files come out in their own formats.

Shubham Dixit

Reviewed by Shubham Dixit

Independent Expert in Email Forensics and Data File Conversion. Shubham reviewed this guide for technical accuracy. He is an independent external reviewer and not an employee of PCDOTS.

Profile  |  LinkedIn