TeamMsgExtractor / msg-extractor

Extracts emails and attachments saved in Microsoft Outlook's .msg files
GNU General Public License v3.0
726 stars 169 forks source link

Reading the example .MSG Files raise errors #416

Closed kashifiqb closed 2 weeks ago

kashifiqb commented 4 months ago

OS macOS Monterey

Installation of API

`pip3 install extract-msg

Code sample Used import extract_msg

msg = extract_msg.openMsg("/Users/kashifiqbal/Documents/extract-msg-code-samples/strangeDate.msg")

Error Generated

Traceback (most recent call last): File "/Users/kashifiqbal/Library/Python/3.9/lib/python/site-packages/extract_msg/msg_classes/msg.py", line 155, in init self.__ole = olefile.OleFileIO(path, raise_defects = defect) File "/Users/kashifiqbal/Library/Python/3.9/lib/python/site-packages/olefile/olefile.py", line 1127, in init self.open(filename, write_mode=write_mode) File "/Users/kashifiqbal/Library/Python/3.9/lib/python/site-packages/olefile/olefile.py", line 1256, in open self._raise_defect(DEFECT_FATAL, "not an OLE2 structured storage file", NotOleFileError) File "/Users/kashifiqbal/Library/Python/3.9/lib/python/site-packages/olefile/olefile.py", line 1166, in _raise_defect raise exception_type(message) olefile.olefile.NotOleFileError: not an OLE2 structured storage file

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/kashifiqbal/Documents/extract-msg-code-samples/extract_msg_api.py", line 3, in msg = extract_msg.openMsg("/Users/kashifiqbal/Documents/extract-msg-code-samples/strangeDate.msg") File "/Users/kashifiqbal/Library/Python/3.9/lib/python/site-packages/extract_msg/open_msg.py", line 90, in openMsg msg = MSGFile(path, **kwargs) File "/Users/kashifiqbal/Library/Python/3.9/lib/python/site-packages/extract_msg/msg_classes/msg.py", line 159, in init raise InvalidFileFormatError(e) extract_msg.exceptions.InvalidFileFormatError: not an OLE2 structured storage file

TheElementalOfDestruction commented 4 months ago

I cannot replicate this issue on other operating systems, so either the file you have is corrupted or it is an issue with Mac OS. Please see if you can verify the hash of the file. The result of an SHA256 hash should be the following: SHA256: 9676ca02b32c15bf47bcf4295131d807a2729c2d1cddc53c4d40b57aa6c6d32b

You can acquire this hash directly through python with the following code:

with open("/Users/kashifiqbal/Documents/extract-msg-code-samples/strangeDate.msg", 'rb') as f:
    print(hashlib.sha256(f.read()).hexdigest())
TheElementalOfDestruction commented 2 weeks ago

Closing this since it's had no response