# Save attachments Retrieve and save attachments from emails, Outlook files, archives, and PDFs. To get and save attachments, follow these steps: 1. Instantiate the [Viewer](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer/) object. Specify a file that contains attachments. 2. Call the [get_attachments](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer/#methods) method. It returns the attachment collection. 3. Iterate through the collection. To save an attachment, call the [save_attachment](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer/#methods) method. The following code snippet shows how to get and save all attachments from the MSG file: {{< alert style="info" >}}NOTE: provided code snippet suits all format families that support attachments: emails, Outlook data files, archives, and PDF documents.{{< /alert >}} {{< tabs "example1">}} {{< tab "Python" >}} ```python from groupdocs.viewer import Viewer def extract_and_save_attachments(): # Load document with attachments with Viewer("with_attachments.msg") as viewer: attachments = viewer.get_attachments() print("\nAttachments:") for attachment in attachments: print(attachment) # Save attachment to disk viewer.save_attachment(attachment, f"./attachments/{attachment.file_name}") print(f"\nAttachments retrieved successfully.") if __name__ == "__main__": extract_and_save_attachments() ``` {{< /tab >}} {{< tab "with_attachments.msg" >}} {{< tab-text >}} `with_attachments.msg` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/python-net/_sample_files/developer-guide/processing-attachments/how-to-extract-and-save-attachments/with_attachments.msg) to download it. {{< /tab-text >}} {{< /tab >}} {{< tab "extract-and-save-attachments-outputs.zip" >}} ```text attachments/delivery-note-0912.xlsx (7 KB) attachments/invoice-NWR-2026-0912.pdf (194 KB) ``` [Download full output](https://docs.groupdocs.com/viewer/python-net/_output_files/developer-guide/processing-attachments/how-to-extract-and-save-attachments/extract_and_save_attachments/extract-and-save-attachments-outputs.zip) {{< /tab >}} {{< /tabs >}}